The generate_get_the_title_parameters
filter allows modify the output of post titles.
For example, we can use this PHP snippet to make the post titles in blog/archive pages to open in a new tab:
add_filter( 'generate_get_the_title_parameters', function( $params ) {
if ( ! is_singular() ) {
$params = array(
'before' => sprintf(
'<h2 class="entry-title"%2$s><a href="%1$s" rel="bookmark" target="_blank">',
esc_url( get_permalink() ),
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
),
'after' => '</a></h2>',
);
}
return $params;
} );
Or make the post titles in blog archive pages from <h2>
to <h3>
:
add_filter( 'generate_get_the_title_parameters', function( $params ) {
if ( ! is_singular() ) {
$params = array(
'before' => sprintf(
'<h3 class="entry-title"%2$s><a href="%1$s" rel="bookmark">',
esc_url( get_permalink() ),
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
),
'after' => '</a></h3>',
);
}
return $params;
} );
Or we can remove the link attached to the post titles in blog/archives pages:
add_filter( 'generate_get_the_title_parameters', function( $params ) {
if ( ! is_singular() ) {
$params = array(
'before' => sprintf(
'<h2 class="entry-title"%s>',
'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
),
'after' => '</h2>',
);
}
return $params;
} );
See more info here.