[Resolved] How to remove an h2 tag that is not suitable for SEO from my website

Tagged: 

  • Author
    Posts
  • #14293

    Andrew Misplon
    Keymaster

    Hi Rafa

    Thanks for reaching out.

    Ultra is using the_post_navigation, you can read more about that function https://developer.wordpress.org/reference/functions/the_post_navigation/. The h2 tags are outputted as part of that function and not directly included in Ultra.

    The h2 tags in question are for screen readers so they are never seen by regular browsers, only for those users making use of screen readers.

    We can use the following filter to change the WordPress core screen reader markup https://developer.wordpress.org/reference/hooks/navigation_markup_template/.

    If you aren’t using a child theme, install a plugin called Code Snippets. Then go to Snippets > Add New, name the snippet as you’d like and insert into the snippet body:

    function ultra_navigation_markup_filter( $template, $class ) {
    	return str_replace( 'h2', 'span', $template );
    }
    add_filter( 'navigation_markup_template', 'ultra_navigation_markup_filter', 10, 2 );

    Finally, enable the option to run the snippet on the site front-end and click Save changes and activate.

    I hope that helps.

    Your english is perfect 🙂

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Scroll to top