Making pages in a menu appear conditionally

You can use wp_nav_menu_objects or wp_nav_menu_items hooks to add your filter function. function my_hide_menu_items($objects) { if ( is_admin() ) return $objects; foreach ( $objects as $k=>$object ) { if ( YOUR CONDITION ) { // if $object shouldn’t be displayed unset($objects[$k]); } } return $objects; } add_filter(‘wp_nav_menu_objects’, ‘my_hide_menu_items’, 10, 2);

Active class to current link

Edit Two things: wp_nav_menu() also outputs .current_page_item, as backward compatibility with wp_page_menu(). Among the list item CSS classes added by wp_nav_menu(), for a custom post type, list items will have a CSS class .list-type-object-{slug}, where {slug} is the CPT slug. So, you could target: .list-type-object-{slug}.current-list-item Original Answer The key is in the class name: .current_page_item. … Read more

Opening Menu link in another tab

When in the Appearance > Menus admin screen, click the Screen Options tab in the upper right corner, then under Show advanced menu properties tick the Link Target box. You’ll now have a check box for each menu item labeled Open link in a new window/tab. That said, many people these days do not take … Read more

Change appearance based on category but post is in two main categories

One easy way is to use has_category function. E.g. in your header you can use if ( has_category(‘pirtek’) ) { $header=”/path/to/pirtek/header” } else { $header=”/path/to/standard/header” } If the post has the ‘kirtek’ category, then the condition inside if is true, no matter what other categories the post belongs to. This kind of if statement can … Read more

How to conditionally add a wp_filter

Edit — fixed the if() statement. function add_nav_class( $output ) { $menu_obj = get_term_by( ‘slug’, ‘footer_menu’, ‘nav_menu’ ); // $menu_obj = get_term_by( ‘name’, ‘Footer Menu’, ‘nav_menu’ ); // if the ‘slug’ version doesn’t work, try the ‘name’ version // Just make sure you’re using the correct name if( ‘footer_menu’ == $menu_obj->name ) ) { return … Read more

Parent Page > Child Page Menu

You have to create a new navigation walker class in your theme, in which you will override the default output to match the one required by Bootstrap. Download a drop-in nav walker class for Bootstrap here and do the following: Load the new walker class in your theme’s template.php file: require_once(‘wp_bootstrap_navwalker.php’); Create the menu in … Read more

Question about Menus on WordPress

You have menu two times as parameter, you probably want: wp_nav_menu( array(‘theme_location’ => ‘main’, ‘menu’ => ‘menu_center’ )); Edit: From your comments I’m getting that you’re missing some information about the whole topic, e.g. the difference between the description and the name of a menu. To resolve this you really should just read the according … Read more

Why can’t I add a custom image in my navigation?

I figured it out. You have to search your style.css file and find /* Buttons */ Under that you will find the following classes .menu-toggle, article.post-password-required input[type=submit], .bypostauthor cite span {} .menu-toggle, button, {} button[disabled], input[disabled] {} .menu-toggle:active, .menu-toggle.toggled-on, button:active, {} There are 2 states of the button that you need to configure. Hover and … Read more