Call custom field into menu item

This is what i have used for checking to see if the custom field is there or not. I am sure you can use it as well. <?php $custom_field = get_post_meta($post->ID, ‘Your Custom Field Name’, true); // Checks to see if there is a value in the custom field if($custom_field != ”) { echo $custom_field; … Read more

How can I add (custom) modules to Appearance -> Menus?

When you register a custom post type, set the argument show_in_nav_menus to TRUE, and WordPress will create the box for you automatically. This works for custom taxonomies too. Example, requires PHP 5.4 or newer. add_action( ‘wp_loaded’, function() { $post_type=”foo”; add_action( ‘registered_post_type’, function( $registered ) use ( $post_type ) { if ( $registered !== $post_type ) … Read more

Deleted pages are NOT removed from custom menus?

Empty your trash 🙂 Pages are not removed from the custom menus until they’ve been deleted completely. I’ve tested it right now. Creating a complex nav menu can take a very long time and the pages can be bulk deleted in a sec. I believe WordPress is just trying to save you all the trouble … Read more

Show current navigation path from menu

The best way would be to use wp_nav_menu with a custom walker. Prerequisites: Registered theme location Menu saved to that theme location Useage Wherever you want the breadcrumbs (for theme location ‘primary’): <?php wp_nav_menu( array( ‘container’ => ‘none’, ‘theme_location’ => ‘primary’, ‘walker’=> new SH_BreadCrumbWalker, ‘items_wrap’ => ‘<div id=”breadcrumb-%1$s” class=”%2$s”>%3$s</div>’ ) ); ?> The custom walker … Read more

Highlight parent menu item when child is not in menu

Alrdy got it: <?php //in functions.php add_filter(‘nav_menu_css_class’, ‘highlight_portfolio’, 12, 2); function highlight_portfolio($classes, $item) { $parent = get_post_ancestors(); $parent_ID = $parent[0]; if ($parent_ID == $item->object_id) { array_push($classes, ‘current-menu-ancestor’); } return $classes; }

Menu limit, cannot add new menu items

I had a similar issue with a client’s server, and the solution in their case was to increase the php max_input_vars setting in php.ini. The number of menu items times the number of attributes for each item was exhausting the allowed input vars, so the server was silently truncating the request, resulting in menu items … Read more

Remove unusable metaboxes in nav menu management screen

There are two important global variables in wp-admin/nav-menus.php: $nav_menus is an array of all available menus, filled with wp_get_nav_menus(). $wp_meta_boxes[‘nav-menus’] is an array of all available metaboxes for this screen. We can hook into admin_head-nav-menus.php, an action called after the first variable has been set up, and change the second variable: add_action( ‘admin_head-nav-menus.php’, ‘t5_hide_dead_menu_metaboxes’ ); … Read more

Using nonce in menu item

Just add a filter: function change_menu($items){ foreach($items as $item){ if( $item->title == “Log Out”){ $item->url = $item->url . “&_wpnonce=” . wp_create_nonce( ‘log-out’ ); } } return $items; } add_filter(‘wp_nav_menu_objects’, ‘change_menu’);

Whats the difference between current_page_item and current-menu-item

current_menu_item is the active element in the menu, independent from the type (page, archives, post, etc.) of the current menu element, while current_page_item only available, if the current item is a page and is current. For more details: http://codex.wordpress.org/Dynamic_Menu_Highlighting