Benefits of using Nav Walker?

I would say mostly you see the usage of wp_nav_menu(), which does use wp_get_nav_menu_items(). You can use wp_nav_menu() with the default walker or a custom walker. To be honest I can’t remember the time I did a menu manually, with wp_get_nav_menu_items() or something else, and I tend to be lazy, so this is definitely more … Read more

How to add a parameter to links in the nav menu?

To add a new attribute to your anchor link for the nav items concatenate $attribute variable with your required attribute. You have commended code just uncomment the code and use those $attributes = ! empty( $item->attr_title ) ? ‘ title=”‘ . esc_atta( $item->attr_title ) .'”‘ : ”; $attributes .= ! empty( $item->target ) ? ‘ … Read more

Second Navigation inside header

Best is always subjective, however, I’d put it in the following manner to have better control and better arrangement of my templates: A structure to have granular control: First, I’d create a new folder, e.g. template-parts in my theme and then inside that, another folder e.g. navigation (to have separate template parts in different folders). … Read more

wp_get_nav_menu_items wp-admin/customize.php problem

I was getting the same fatal error after creating a similar dynamic menu. What fixed the issue for me was redefining the default values: $post->target=””; $post->attr_title=””; $post->description = ”; $post->classes=””; $post->xfn = ”; $post->status=”publish”; $post->original_title=””; So your foreach loop would look like this: foreach ( get_posts( $category_ten_last_posts ) as $post ) { $post->menu_item_parent = $item->ID; … Read more

Second nav is merged with the first in mobile

In functions.php, change the function magazine_responsive_menu_settings() to the following: function magazine_responsive_menu_settings() { $settings = [ ‘mainMenu’ => __( ‘Menu’, ‘magazine-pro’ ), ‘subMenu’ => __( ‘Submenu’, ‘magazine-pro’ ), ‘menuClasses’ => [ ‘combine’ => [ ‘.nav-primary’, ‘.nav-header’, ], ], ]; return $settings; } Basically, in the combine, I removed ‘.nav-secondary’, This is how it looks like now

BuddyPress – How to add logout in nav menu

Google is your friend. Here is a snippit I found I didn’t test it but seems logical. // functions.php function add_login_logout_link($items, $args) { if(is_user_logged_in()) { $newitems=”<li><a title=”Logout” href=””. wp_logout_url(‘index.php’) .'”>Logout</a></li>’; $newitems .= $items; } else { $newitems=”<li><a title=”Login” href=””. wp_login_url(‘index.php’) .'”>Login</a></li>’; $newitems .= $items; } return $newitems; } add_filter(‘wp_nav_menu_items’, ‘add_login_logout_link’, 10, 2); Source

adding .current* tags to custom post types and taxonomies

The classes are not added by the Twenty Ten theme, but by the common custom navigation menu code, in _wp_menu_item_classes_by_context(), which is called from wp_nav_menu(). If you want to add extra classes you can do that by either hooking into wp_nav_menu_objects, called once with the whole menu tree, or into nav_menu_css_class, called when rendering each … Read more

Previous & Next on Index Page broken

I had the exact same problem a while ago on one of my themes. My problem was that the theme used query_post to filter out some posts. This caused the pagination to fail. I think this was the code that solved it: <?php if ( is_home() ) { $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; … Read more

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