Problem with registering menus – What to do when other solutions aren’t working?

In regard to this comment: I see – I had things nested incorrectly in my functions.php file – I found that the register_nav_menus() call should not be nested within the theme setup function (function hchw_setup()) To the contrary, inside a callback hooked into after_setup_theme is exactly the right place for calls to register_nav_menus(). Your problem … Read more

Determine which theme location a wp_get_nav_menu_items is for

Not sure this is the simplest means, but you could conditionally add the filter to just the location you want to modify via wp_nav_menu_args filter when wp_nav_menu is called, then immediately remove the filter so it isn’t applied to other menus. function wpa108544_nav_menu_args( $args ){ // check if it’s the location we want the filter … Read more

Which settings/options are saved on a theme-basis and how does this affect theme-switching?

After doing some research this answer became a bit longer than expected, but this is the essence: TL;DR: Menu placement and Widget placement/order is saved on a Theme basis and can therefore be restored when switching Themes. This does not include the individual settings of Menus and Widgets, so if you change them these changes … Read more

Walker class: Problems with understanding how walk() method can be called without error

Per comments, it’s called with call_user_func_array, so the 1st 2 elements get assigned to the declared arguments $elements and $max_depth, leaving the third element ($r which is the original $args) to be assigned via array_slice to $args. Eg function wpse172812( $elements, $max_depth ) { $args = array_slice(func_get_args(), 2); error_log(“elements=$elements, max_depth=$max_depth, args=” . print_r( $args, true … Read more

Adding a within ‘s from wp_nav_menu()

Yes, items_wrap is used to to modify or replace the default <ul> wrapper. To wrap the individual links inside of that element, simply use link_before and link_after, like so: wp_nav_menu( array( ‘theme_location’ => ‘some-location’, ‘link_before’ => ‘<span>’, ‘link_after’ => ‘</span>’, ) );

Walker_Nav_Menu: put custom code between a particular

You need to make your own walker menu (i am guessing you already know that), and the best way i think is overriding the function that ends each menu item which is end_el : class logo_in_middle_Menu_Walker extends Walker_Nav_Menu { public $menu_location = ‘primary’; function __construct($menu_location_var) { // parent class doesnt have a constructor so no … Read more

How do I give class to the dropdown sub-menu in the wp_nav_menu?

You can use Walker_Nav_Menu (WordPress Default class). Here is an example – In header.php file – <nav id=”header-menu”> <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘walker’ => new Child_Wrap() ) ); ?> </nav> In my functions.php file – class Child_Wrap extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat(“\t”, $depth); … Read more

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