• Resolved jbgglgdev

    (@jbgglgdev)


    Hi, I noticed the <h2 class="screen-reader-text">some article title</h2>; for post navigation. Is it possible to change that <h2> by a single ?

    Thank you
    JB

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    • This topic was modified 7 years, 6 months ago by bdbrown.
    • This topic was modified 7 years, 6 months ago by bdbrown.
    • This topic was modified 7 years, 6 months ago by bdbrown.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jbgglgdev

    (@jbgglgdev)

    By single text, no h2.

    Hi @jbgglgdev,

    What do you mean by single text? You should be able to filter the <h2> markup inside of the post navigation using some of the built in filters in WordPress core.

    If you are using a child theme, you can add the following function to your themes functions.php file. If not, you may want to setup an MU plugin to add the code to. We have setup a documentation page outlining how you can setup an MU plugin on our Github repo for this theme, here.

    
    /**
     * Filter the post navigation screen reader text.
     *
     * @author GoDaddy
     *
     * @param string $template Markup for the screen reader text.
     * @param string $class    Screen reader navigation class.
     *
     * @return Markup for the post navigation template.
     */
    add_filter( 'navigation_markup_template', function navigation_markup_filter( $template, $class ) {
    
    	return str_replace( 'h2', 'span', $template );
    
    }, 10, 2 );
    

    Once added to functions.php of your child theme or the MU plugin you can save the file. The <h2> inside of the post navigation markup should then me set to <span> tags. You can set span to any element you’d like to use.

    Let us know if that helps.

    Best,
    Evan

    Bonjour,
    votre code :
    /*site internet top*/
    /**
    * Filter the post navigation screen reader text.
    *
    * @author GoDaddy
    *
    * @param string $template Markup for the screen reader text.
    * @param string $class Screen reader navigation class.
    *
    * @return Markup for the post navigation template.
    */
    add_filter(‘navigation_markup_template’, function navigation_markup_filter( $template, $class ) {

    return str_replace( ‘h2’, ‘span’, $template );

    }, 10, 2 );
    Réponse : Parse error: syntax error, unexpected ‘navigation_markup_filter’ (T_STRING), expecting ‘(‘ in /homepages/2/d505216444/htdocs/site-internet-top.fr/wp-content/themes/site-internet-top.fr/functions.php on line 130

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘h2 class=screen-reader-text’ is closed to new replies.