Add/Remove current_page_parent class

Replace news with your custom post type and menu-item-000 with the menu item you want to highlight. function wpdev_nav_classes($classes) { // Remove “current_page_parent” class $classes = array_diff( $classes, array( ‘current_page_parent’ ) ); // If this is the “news” custom post type, highlight the correct menu item if ( in_array(‘menu-item-000’, $classes) && get_post_type() === ‘news’ ) … Read more

wp_nav_menu add something before closing container and after last list item

I think you can use: ‘items_wrap’ => ‘<ul id=”%1$s” class=”%2$s”>%3$s <div class=”foo”>bar</div> </ul>’, as a wp_nav_menu() argument. We’re using this part of the wp_nav_menu() function: $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items ); where the items_wrap argument contains the following sprintf specifiers: %1$s to match the wrap id %2$s to match … Read more

How To Remove Duplicate Menu Locations

You register an array of four menus. If you reformat your code, you will see it. […] array( ‘primary-nav’, __( ‘Primary Menu’), ‘footer-nav’, __( ‘Footer Menu’) ); […] Adapt your code to an array with custom keys and you will be fine: […] array( ‘primary-nav’ => __( ‘Primary Menu’), ‘footer-nav’ => __( ‘Footer Menu’) ); … Read more

CSS for menu item added via functions.php

Normally, menu items are rendered as an <li> tag with an <a> tag inside. You could simply wrap $todaysdate in an anchor so that this item will be styled like the others: add_filter(‘wp_nav_menu_items’,’add_todaysdate_in_menu’, 10, 2); function add_todaysdate_in_menu( $items, $args ) { if( $args->theme_location == ‘header-menu’) { $todaysdate = date(‘l jS F Y’); $items .= ‘<li … Read more