Archived topic
changing h2 tags in search result
3 replies · Started by Aaron on January 13, 2022
Viewing posts 1–4 of 4
I use a header element with a h1 in my search results page, and changed the search title to be within a h2 tag.
How do I change the markup for the results heading from h2 to h3?
Hi there,
this filter allows you to change the title parameters:
https://docs.generatepress.com/article/generate_get_the_title_parameters/
The second snippet can be changed to just target the search results:
add_filter( 'generate_get_the_title_parameters', function( $params ) {
if ( is_search() ) {
$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;
} );
Thank you for your support, really nice!
Glad to be of help
This archived topic is closed to new replies.