register_nav_menus, then create menus programatically

There is no need to create/update custom menus programmatically, just to do what you’re trying to do. Just rely on the wp_nav_menu() fallback, wp_page_menu(), or define your own, custom callback, e.g. to output wp_list_pages(). Calling this: `wp_nav_menu( array( ‘theme_location’ => ‘main-nav’ ) );` …will, if no custom menu has been assigned to the ‘main-nav’ theme … Read more

Does is_child() exist in wp 3.5.1?

To check for a specific parent ID use $post->post_parent==”123″ and replace “123” with the parent ID of your choice. I learned how to do this by using the Widget Logic plugin. From the Widget Logic notes: global $post; return (is_page(‘pagename’) || ($post->post_parent==”13″)); — home page OR the page that’s a child of page 13 Edit: … Read more

Use wp_logout_url() in menu creation page

Add submenu with a custom link, /wp-login?action=logout, like the image below: Add code like below in functions.php: function wpa_remove_menu_item( $items, $menu, $args ) { if ( is_admin() || ! is_user_logged_in() ) return $items; foreach ( $items as $key => $item ) { if ( ‘Login / Register’ == $item->title ) unset( $items[$key] ); if ( … Read more

How to add attribute in menu code

If you want WordPress to add these items dynamically you would need to add a custom walker class to your menu declaration. Find where your menu is declared in the theme and add a custom walker class name in their wp_nav_menu function: wp_nav_menu( array ( ‘menu’=> ‘main-menu’, ‘container’=> ”, ‘walker’ => new Description_Walker)); The menu … Read more

How to use my menu PHP code as sidebar?

wp_nav_menu is a standard WordPress function, so you would just copy/paste that PHP code into sidebar.php using whatever additional arguments you need. However, since the theme has a sidebar.php it probably has widget areas, so I would look in Appearance > Widgets in the dashboard and look for a sidebar widget area. In there, I … Read more

Removing specific menu items?

A much simpler solution is to use remove_menu_page , remove_submenu_page and remove_menu (admin bar). Your example of removing the sub-menu item for “add new” would be remove_submenu_page( ‘edit.php?post_type=page’, ‘post-new.php?post_type=page’ ); To remove it from the admin menu bar you can use the example in @BandonRandon’s post.