How to display different submenus?

It is ok to put other elements as child elements. I don’t see any problem with this. To add custom elements you have to add custom metabox to menu administration. WordPress will handle saving your custom elements automatically so you don’t need to worry about this. To display your custom elements you can create custom … Read more

Add custom class to li element which has children

Please take a look at this walker class (Bootstrap Nav Walker) you’ll get a good understanding of how things work inside a walker. There is a has_children property in $args argument $args->has_children. You can use this to check if the current item has any children or not like the following code if ( $args->has_children ) … Read more

Remove a class from a using Walker

You don’t need to use the Walker to remove classes from nav menu items. There is a filter, nav_menu_css_class which can be used to modify the classes on menu items. Filters the CSS class(es) applied to a menu item’s list item element. This, for example, would remove the classes from all menu items: add_filter( ‘nav_menu_css_class’, … Read more

Custom Category Walker with Image, Fallback to Most Recent Post in Category Image

The solution to the problem is that the tax_query needs to be an array of arrays. Thank you Sally CJ for the comment above, which also reminded me to $query->request. Here’s the total Walker for anyone for whom it’s useful: class List_Category_Walker extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), … Read more

Wrapping menu’s top-level link and sub-menus in div

This would do it: class My_Walker_Nav_Menu extends Walker_Nav_Menu { private $_before = null; public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { // Backup the original “before”, if any. if ( null === $this->_before ) { $this->_before = $args->before; } // Now add the wrapper div, if applicable. … Read more

Displaying Nav Menu

Yes, wp_nav_menu displays all levels of menu by default. You don’t have to write your custom walker class to display submenu items – WordPress already has one which is used by default. WP_Bootstrap_Navwalker is used only because given theme uses Bootstrap and nav menu should generate custom HTML code, which is compatible with Bootstrap. The … Read more

wp_list_categories walker without links on categories that have subcategories (to make a nested dropdown menu)

If you say the wp_list_categories output format is ok to you and all you need is only to remove the links from parent categories, try the following code (you can add it to your functions.php): add_filter( ‘wp_list_categories’, ‘sanitize_list_categories_links’, 10, 2 ); function sanitize_list_categories_links( $list, $args ) { if ( isset( $args[‘sanitize_links’] ) && $args[‘sanitize_links’] ) … Read more

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