wp_nav_menu exclude post or page by ID
-
Hi,
I know there is any mention to exclude parameter for wp_nav_menu in the codex, but also found some posts saying this is posible, I try many of it and don′t work.
In my case I′m creating a custom widget for my theme, and this widget shows custom menu, what I want is if is in a page which are listed in the menu the item of this page was remove form the menu, so first I get the ID and I use this variable in the exclude.
<?php global $wp_query; $page_id = $wp_query->post->ID; ?> <!--BEGIN #joinn-us--> <aside id="related-content" class="widget panel"> <h4 class="widget-title"><?php _e('Related Content','udla'); ?></h4> <?php wp_nav_menu( array( 'theme_location'=> 'related-menu', 'menu_class' => 'side-nav', 'container' => '', 'container_class' => '', 'exclude' => $page_id ) ); ?> </aside> <!--END #join-us-->
Should I use the
fallback_cb
parameter?
Or do I need to set a function to use this parameter?Thanx for any help.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘wp_nav_menu exclude post or page by ID’ is closed to new replies.