Site logo

Archived topic

Auto-generated links inside h2 tags

3 replies · Started by John on March 30, 2021

Viewing posts 1–4 of 4

Like you guys, I'm using bbpress plugin to add forums to my site. However, titles on some pages contain links inside the h tags that point to the same page you are already on.

Exactly like the same on yours too:
https://generatepress.com/forums/search/hello/

Search Results for 'hello' h2 tag contains a self-link.

These are triggered by the theme (tested with another one and they weren't there).

Is there a snippet or some other solution for this?

I know the CSS "pointer-events: none;" workaround but would like to get rid of the redundant links entirely.

Hi there,

I'm not exactly sure what element you're pertaining to.

Can you provide us any screenshots of what h texts you're pertaining to?

Also, can you link us to the site in question? So we can check the page source for selectors to have a better idea of which is adding the h tags you mentioned.

Let us know. :)

Already found a solution myself.

add_filter( 'generate_get_the_title_parameters', function( $params ) {
    if ( function_exists( 'is_bbpress' ) && is_bbpress() ) {
        $params = array(
            'before' => sprintf(
                '<h2 class="entry-title"%s>',
               'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
            ),
            'after' => '</h2>',
        );
    }
    return $params;
} );

Nice one. Thank you for letting us know.

Glad you got it sorted. :)

This archived topic is closed to new replies.