wp_get_nav_menu_items vs wp_nav_menu

wp_get_nav_menu_items function retrieves an array of menu items for given menu. But the menu is a hierarchy, so there is a need of creating some mechanism that will create that hierarchy based on list of menu items. On the other hand there already is wp_nav_menu, that will get items for that menu (using wp_get_nav_menu_items) and … Read more

Highlight the “Home” / “Blog” button while on main page

WordPress marks the currently displayed page in the menu with CSS classes .current-menu-item, .current-menu-parent, .current-menu-ancestor. Add the required styles to highlight items using these classes. Sample Menu: * Blog * First Category * Second Category * About * Contact When you open blog page, the corresponding menu item (“Blog“) has a class .current-menu-item. Similarly, when … Read more

WP /wp-admin/admin-ajax.php produces 404

Your /wp-admin/admin-ajax.php might have been modified by another php file or plugin. Try downloading a copy of your wordpress version and overwrite admin-ajax.php with the original source file. If that doesn’t work, try deactivating your plugins (or theme) one by one until you notice a difference.

How to dynamically add custom taxonomy terms as a sub-menu of an existing menu item, using custom walker class

Okay, I figured it out. It’s not very smooth, but at least it works as I want it to. Will have to do some refactoring. The issue was that wp_nav_menu() got called earlier than the taxonomy registration. I had accidentally placed it in my theme-functions.php and forgotten about it, then called it again in my … 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

Automatically add product_categories to nav_menu

put this on your functions.php and then call the function in whatever page desired. this code is prepare to use css. if (! function_exists(‘menu_categories’)) { function menu_categories(){ $cat_args = array( ‘orderby’ => ‘name’, ‘order’ => ‘asc’, ‘hide_empty’ => true); $cats = get_terms( ‘product_cat’, $cat_args ); ?> <h1>Categories</h1><?php foreach ($cats as $key => $cat): if ($cat->parent … Read more