How to add a custom metabox to the Menu Management admin screen?

I succeeded in this, but it is a mess. Basically, the walker should have the following parameters: $this->db_fields[‘parent’] = ‘post_parent’; $this->db_fields[‘id’] = ‘ID’; But, to get that in place, you need to rip out the existing metabox callback, copy it, change one line so you get an extra filter, and place it back. Then you … Read more

How to get IDs for objects in menu branch?

I am lazy to write supporting logic from scratch so I am reusing functions from linked answer on branches: /** * Retrieve IDs of posts in branch of menu. * * @param mixed $menu * @param string $branch_title * * @link http://wordpress.stackexchange.com/questions/2802/display-a-portion-branch-of-the-menu-tree-using-wp-nav-menu * * @return array */ function get_post_ids_from_menu_branch( $menu, $branch_title ) { $menu_object = … Read more

Display only page specific sub menu items using Custom Walker

Here is a much simpler implementation: class UL_Submenu_Walker extends Walker_Nav_Menu { private $hidden = false; function start_lvl(&$output, $depth) { if($depth == 0) { $style = $this->hidden ? “” : “display:none;”; } $output .= “<ul class=\”submenu-“.$depth.”\” style=””.$style.””>”; } function start_el(&$output, $item, $depth, $args) { $class_names = $value=””; $classes = empty( $item->classes ) ? array() : (array) … Read more

Creating “static” taxonomies to choose from, inside custom post type?

Make it show_ui => false Then to show it on the post edit screen add the box manually add_action(‘add_meta_boxes’, ‘meta_boxes_function’); function meta_boxes_function() { add_meta_box(‘categoriesdiv’, ‘categories’, ‘post_categories_meta_box’, ‘blurb’, ‘side’, null, array(‘taxonomy’ => ‘categories’)); } use this code for every static term if(!term_exists(‘term1’, ‘categories’)) wp_insert_term(‘term1’, ‘categories’);

How can I create an auto-populated menu that is automatically assigned to a location?

So basically you are asking how to create a custom menu by code and assign it to a menu location: //give your menu a name $name=”theme default menu”; //create the menu $menu_id = wp_create_nav_menu($name); //then get the menu object by its name $menu = get_term_by( ‘name’, $name, ‘nav_menu’ ); //then add the actuall link/ menu … Read more

Use wp_nav_menu() to display a Menu from another site in a Network install?

This is what I’ve used recently. It’s very simple but it works well for me. function wp_multisite_nav_menu( $args = array(), $origin_id = 1 ) { global $blog_id; $origin_id = absint( $origin_id ); if ( !is_multisite() || $origin_id == $blog_id ) { wp_nav_menu( $args ); return; } switch_to_blog( $origin_id ); wp_nav_menu( $args ); restore_current_blog(); } I’ve … Read more

register_nav_menus() won’t register menus

You don’t need to add any action to register your Nav Menu. Here are some quick steps for you to get your WordPress Nav Menu to work… Register Nav Menu if (function_exists(‘register_nav_menu’)) { register_nav_menu(‘header_menu’, ‘Header Menu’); } Define and Use Nav Menu in your Theme: Usually we place the Menu DIV code in header.php file; … Read more