Forums
Home / Themes and Templates / using $class to add text to wp_menu_nav
(@sebvass)
9 years, 10 months ago
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',
$class = "new!"
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…
H1 class
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