Overriding wp_nav_menu default arguments

If you want the options to be extensible by developers, just add a custom filter to the output: wp_nav_menu( apply_filters( ‘wpse119371_nav_menu_args’, array( ‘theme_location’ => ‘primary’, ‘container’ => false, // etc. ) ) ); Then, a developer merely has to add a filter callback: function wpse119371_filter_nav_menu_args( $args ) { // Modify $args $args[‘container’] => ‘div’; // … Read more

Menu is not visible in appearance

I have done a complete answer on this a while ago on SO. You can see the complete post here. For the sake of WPSE users, I have copied my answer from that post. I have not edited it, this post was originally about adding and displaying a nav menu to the footer, but the … Read more

Pass a parameter to a menu walker

As @toscho said, you can call the walker class with parameters as you did: new BEMwalker( ‘mobile’ ) The constructor of BEMwalker will take the arguments (like any other function or method in PHP) so you can access the parameter(s) via $this: class BEMwalker extends Walker_Nav_Menu { private $classes; public function __construct( $classes=”” ) { … Read more

Using string instead of object class instantiation on the walker argument breaks wp_nav_menu

Apparently custom nav menu walkers are not supported though they were supposed to be. I’m surprised this only has been discovered now. However, there is an easy fix for you to get them to work. Just add this to your theme: add_filter( ‘wp_nav_menu_args’, function( $args ) { if ( isset( $args[‘walker’] ) && is_string( $args[‘walker’] … Read more

What does a walker menu mean?

Walker_Nav_Menu is the core class to handle navigation menus. You can use it to handle your navigation menu, or you can create your own children class that extends this class. If you decide to use your own class, then you must pass an instance as an argument when you use wp_nav_menu() class myWalkerClass Extends \Walker_Nav_Menu … Read more

How to var_dump nav menu items from anywhere?

The items are set up in wp_nav_menu(). There is a useful filter you can use: ‘wp_nav_menu_objects’. It offers the items as $sorted_menu_items and the arguments of the wp_nav_menu() call as $args. From wp-includes/nav-menu-template.php::wp_nav_menu(): $sorted_menu_items = apply_filters( ‘wp_nav_menu_objects’, $sorted_menu_items, $args ); So … hook into this filter, store the data somewhere, return the $sorted_menu_items unchanged and … Read more

Menu items id’s – are they 100% unique?

Yes it is always unique. id 814 cant be applied again unless you update it manually on your DB. Its because of auto increment .. DB automatically increment id so everytime next id will be +1 814 815 816 and so on.. Even if you delete an id in between. It wont affect auto incrementation. … Read more

How to register custom menu widget

Try this code (in function.php) class MyWidget extends WP_Widget { function __construct() { $widget_ops = array( ‘description’ => __(‘Use this widget to add one of your custom menu as a link list widget.’) ); parent::__construct( ‘custom_menu_widget-1’, __(‘My name’), $widget_ops ); } function widget($args, $instance) { // Get menu $nav_menu = ! empty( $instance[‘nav_menu’] ) ? … Read more

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