There are moments when you want to hide or show different menu items depending on some conditional logic. Looking to show different navigation menu items for different pages in WordPress? Maybe just to show a different menu to logged in users, or hiding a menu item on particular pages? If you are a developer or know some WordPress essentials – sure you could do this with some custom CSS maybe but I think it’s much easier to do it from the admin? We previously had this question and decided it is a good read for everybody else.

It’s not really recommended to do this, so we’ll share the solution that we found. It’s a WordPress plugin called simply IfMenu. It works out of the box. Let’s start from visiting Appearance -> Menus and get to editing your navigation menus.

Ok, let’s start by choosing a menu item in the navigation and check the ‘Enable Conditional Logic’ checkbox. Once clicked, you will get something very similar to the screenshot below:

As you can see from the screenshot, it’s quite easy to select what you want to do with each menu item. For example, only show the logout page link when a user is logged in. Easy, huh?

After choosing a condition, simply press the save menu button to store your changes and refresh your website. You should be able to see the changes/settings in action.

Custom made logic (by you)

IfMenu is a simple plugin so there are not many conditions that you can apply. We all know WordPress provides many more conditional tags that you can use in your projects. For details you can check the WordPress codex on this page. You can add any of these conditional tags to be used with the IfMenu plugin. For example, let’s assume that you want to show/hide a menu item on custom post type pages. Sure, you could add the custom code in the theme’s functions.php file but this, as we know is not a good practice.

A sample code for this would be:

add_filter( 'if_menu_conditions', 'sow_new_menu_conditions' );

function sow_new_menu_conditions( $conditions ) {
$conditions[] = array(
'name' => 'If it is Custom Post Type archive', // name of the condition
'condition' => function($item) { // callback - must return TRUE or FALSE
return is_post_type_archive();

return $conditions;

After adding this into the theme/plugin code – you should get something similar to the screenshot below:

That is all. Simple, easy to use and directly from the WP Dashboard – that is something almost anybody asks.