wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Insert calendar into wp_nav_menu

wordpress snippet

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.

snippet :  PHPcopy
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>';
}

Did you like this post? If so please share it with your friends. Thanks!