How to hide page links from theme menu

Most of users use wp_nav_menu to output the menu in a theme, then you could make use of the callback function that is passed in the arguments array. wp_nav_menu( array( ‘fallback_cb’ => ‘wp_page_menu’ ) ); wp_page_menu is the default value for the callback function. Looking further, wp_page_menu has an exclude key in its arguments array. … Read more

WordPress Menu Exchange for Mobile Layout

There isn’t an is_mobile() function to my knowledge. WordPress uses a wp_is_mobile() which is probably what you’re looking for. So it should look like this: <?php if ( wp_is_mobile() ) { wp_nav_menu( array(‘menu’ => ‘mobile’ ) ); } else { wp_nav_menu( array(‘menu’ => ‘primary’ ) ); }; ?> EDIT After reviewing your question further it … Read more

active menu in post page

The below filter adds your class based on title, you could also do this by post ID if you’d like: $item->object_id == 123 function wp_nav_parent_class( $classes, $item ) { if( is_singular(‘post’) && $item->title == “Your Menu Item Title Here” ) array_push($classes, ‘current_page_parent’); return $classes; } add_filter(‘nav_menu_css_class’, ‘wp_nav_parent_class’, 10, 2); If is_singular(‘post’) does not work try … Read more

wp_nav_menu without menu or theme_location specified

I am not confident I am following your description completely, but verbatim from the documentation: If not given a theme_location parameter, the function displays the menu matching the ID, slug, or name given by the menu parameter; otherwise, the first non-empty menu; otherwise (or if the menu given by menu is empty), output of the … Read more

Custom Menu Anchor Links Not Working

First: congrats! The links are well formed, so that is not your problem. <a id=”rsvp” rel=”m_PageScroll2id”></a> Is not the convention in HTML5 anymore. You should prefer to put the ID in your H2 element. Something like this: <h2 class=”entry-title” id=”rsvp”>RSVP</h2> Using Google Chrome, when I tried that, I still got the same problem: your entire … Read more

Get current post’s nav menu name (term name)

You are missing a link. The posts are not assigned to the menus directly. There is a post type nav_menu_item in nav_menu taxonomy which links posts (or other kinds of destinations) to their place in menu. This snippet should get you started on retrieval: $menu_items = get_posts( [ ‘post_type’ => ‘nav_menu_item’, ‘meta_query’ => [ [ … Read more

Is it possible to dynamically register menus?

Register a menu is really register a menu location, but I think you don’t need to register locations so you can avoid the register step. I think what you need is wp_nav_menu( ) function. For example, in the page template: //Get the menu slug stored in page custom meta field //Replace menu_meta_field_name with the correct … Read more