Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm looking for a function 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 beginning to understand... I'm trying 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 uderstand how to use $class = "new!" to display the "new!" text just next to my "books" name in the menu...

Sorry again for my bad english...

share|improve this question
Nothing you posted looks like a navigation menu, nor does it look like code hooked into one. Please post the code in more context. It is not clear what you are doing. –  s_ha_dum May 26 '14 at 15:17
right... I found the code here on another subject... the right code is: $args = array( 'numberposts' => '5', 'post_type'=>'books',); $recent_post = wp_get_recent_posts( $args ); if (strtotime($recent_post[0]['post_date']) > strtotime('-1 days')) $class="new!"; I put it on the function.php But I really dont know how to integrate it to the wp_nav_menu... inside my sidebar, I only call the navigation menu as: <div id="" role="navigation"> <?php wp_nav_menu(array('theme_location' => 'menuside',?> </div> –  sebvass May 26 '14 at 16:29
, this is the subject how helped me to find this code...I really want to do the same thing, actually [link]stackoverflow.com/questions/16257753/… –  sebvass May 26 '14 at 16:34
edit your code into the question please. Code formatting in the comments is almost non-existent, making code in the comments very hard to read. –  s_ha_dum May 26 '14 at 17:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.