X

Insert calendar into wp_nav_menu

Needed this for a recent project as a client wanted to display the wordpress calendar as a dropdown item within the menu. Add this snippet to the functions.php of your wordpress theme will add a new menu item to your wp_nav_menu that has a submenu calendar.



Code Snippet:


add_filter('wp_nav_menu_items','add_calendar', 10, 2);
function add_calendar($items, $args) {
if( $args->theme_location == 'header-navigation' )
return $items . '<li><a href="#">Calendar</a><ul class="sub-menu"><li>' . get_calendar(true,false) . '</li></ul></li>';
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!