WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I have a news website. The designers want me to have a link in the menu that says "Latest News - [time of the last post]".

I know I can get the datetime of the latest post with get_lastpostdate().

But how can I put this php code inside the menu? This specific link is not the first one nor the last. It's inside the menu structure. Menus in this website are made trough the usual custom menu tools of wp.

Any ideas?

share|improve this question
Using Navigation Walker class you can customize menu items in WP menu. Check this – Nilambar Jul 4 '14 at 9:15
What should I look for? Ok, extend the walker class. But how can I access from inside the walker one specific menu item and add code to it? Wouldn't a filter be better? Because I really have to do this just once. – Alevalentini Jul 4 '14 at 9:32
Yes, you can also use filter. Filter wp_get_nav_menu_items is available. args parameter is passed in both Walker class and filter also. Both method is applicable and you can choose any one. In filter three parameters are passed. return apply_filters( 'wp_get_nav_menu_items', $items, $menu, $args ); – Nilambar Jul 4 '14 at 9:53
Should I use $item to pass the name of the menu link? – Alevalentini Jul 4 '14 at 10:20

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.