Support » Themes and Templates » using $class to add text to wp_menu_nav

  • I would like to add a “new” label in front of my custom post type name in my navigation menu. The code is :

    <?php $args = array( 'numberposts' => '1' );
    $recent_post = wp_get_recent_posts( $args );
    if (strtotime($recent_post[0]['post_date']) > strtotime('-7 days'))
        $class = "new!";

    I begin to understand… I try to change $class = "new!" by a simple text like echo 'test',

    It works but the text isn’t just in front of the post-type name… same thing using H1 class or something like that…

    So my last step is to understand how to use$class = "new!" to display the “new!” text just next to the “books” name in the menu.

    ps: sorry for my bad english

  • The topic ‘using $class to add text to wp_menu_nav’ is closed to new replies.