Use wp_nav_menu to dynamically generate child menus

My solution uses the Walker_Nav_Menu and a custom class and is mostly hacked together from this post: How do I dynamically populate wp_nav_menu from a custom taxonomy? Solution: //define the custom post type //could use “page” or “post” as well. define(“MENU_CPT”, “action”); //custom function for selecting posts based on a page parent (ne’ term_id) function … Read more

menu items toggle and display on screen size reduction

This is most likely the default behavior for Twenty Twelve; responsive for small screens and thus stacking elements on the page, including the contents of your nav, #site-navigation. Let’s looks at the nav section in the default TT theme: <nav id=”site-navigation” class=”main-navigation” role=”navigation”> <h3 class=”menu-toggle”>Menu</h3> <a class=”assistive-text” href=”#content” title=”Skip to content”>Skip to content</a> <div class=”nav-menu”> … Read more

Rogue current menu item class in wp_nav_menu()

From look at core this is coming from this: // back-compat with wp_page_menu: add “current_page_parent” to static home page link for any non-page query if ( ! empty( $home_page_id ) && ‘post_type’ == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) $classes[] = ‘current_page_parent’; It seems to be some legacy thing, I would … Read more

Walker for menus

All of the methods are being overridden when you load your own walker, but typically you would extend another Walker which works a bit like “filtering” or “pluggable functions”. Take a look at this very simple walker from another question: class my_extended_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output … Read more

Image menu on responsive WordPress

I’m not sure what you are asking for, but I think you need some general suggestions. So: 1) Websites are made by three layers. WordPress (like others good CMS) creates “only” TEXT menu because this is the (fundamental) semantic layer. 1-b) Then, you can always add a presentation layer (css) or a behaviour layer (javascript) … Read more

Custom Class to wp nav menu

This is an old question, but might be very much relevant still today so I thought I would drop a piece of code I developed over the years. It’s basically as close as you can get to customizing classes on every element of a menu in WordPress without developing a custom Nav Walker. This is … Read more

adding a numbers to a item from navigation menu

You can target the location like this: function wpa_filter_nav_menu_objects( $items, $args ){ if( $args->theme_location === ‘primary’ ){ foreach( $items as $item ){ if( strtolower( $item->title ) === ‘sample page’ ){ $item->title = $item->title . ‘(10)’; } } } return $items; } add_filter( ‘wp_nav_menu_objects’, ‘wpa_filter_nav_menu_objects’, 10, 2 ); You can also try $args->menu_id if you use … Read more

TwentyTwelve child theme: Incorrect footer menu

I expect that the theme_location is “footer” not “Footer”. It is case sensitive. I just checked. If you use a bad theme_location wp_nav_menu will fallback to what looks like a page menu when I test it. Edit: Due to additional information in the question, the theme_location is footer-menu and not footer. If you look at … Read more

Determine if a navigation item has children

You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more

How to use my custom menus as seperate pages?

You have to create a corresponding “Page” for the items in your menu, unless those items are things that would have an automatically generated page, like a category archive or author archive. You would then select those items when you create the menu.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)