Menu items (all menus) being deleted randomly on their own [duplicate]

Here are two loggers to help you to tackle the problem. 1) If you want to know when the number of nav menu items changes, you can use the following logger: /** * A logger for nav menu items count – writes to the nav.log file. * * @link http://wordpress.stackexchange.com/a/149394/26350 */ add_filter( ‘wp_get_nav_menu_items’, function( $items, … Read more

How show sub menu only using wp_nav_menu()

I’ve made a free plugin which solves this problem! https://wordpress.org/plugins/wp-nav-menu-extended/ This plugin extends the native wp_nav_menu function and adds additional options: level : (integer) (required for this plugin to work) The level of the navigation menu to show. If no child_of parameter is passed, it shows all the items of this level child_of : (string|integer) … Read more

Create a formatted table-like menu

I think your question is a perfect example for the XY Problem. In WordPress you do not create such a menu in a post editor. You use a menu. Once you start thinking about your problem from this point, everything is easy. 🙂 First register a custom navigation menu for this list in your theme’s … Read more

Determine if a navigation item has children

You can filter wp_nav_menu_objects and add the classes in one rush. You don’t even need a custom walker for that. add_filter( ‘wp_nav_menu_objects’, ‘add_has_children_to_nav_items’ ); function add_has_children_to_nav_items( $items ) { $parents = wp_list_pluck( $items, ‘menu_item_parent’); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = ‘has-children’; return $items; } The class has-children will … Read more

How to set limit only on top levels of wp_nav_menu?

According to the codex, you just need to use depthparameter to display only top-level pages : <?php wp_nav_menu( array( ‘location’ => ‘your_location’, ‘depth’ => 1 ) ); ?> For more reference see this. You could also fix both of your problem by using [wp_get_nav_menu_items][2] and then using a custom loop to parse only first and … Read more

How to add active class on current menu item page?

You could add conditional classes for each in your child theme functions file: Here’s one example you can modify to suit your own needs. add_filter(‘nav_menu_css_class’ , ‘wpsites_nav_class’ , 10 , 2); function wpsites_nav_class($classes, $item){ if( is_archive() && $item->title == “Products”){ $classes[] = “products-class”; } return $classes; Source http://codex.wordpress.org/Function_Reference/wp_nav_menu#Adding_Conditional_Classes_to_Menu_Items You can then style your nav menu … Read more

How to custom output wp_nav_menu()

You will have to use a custom Walker for your menu. Here is the page in the codex that explains it: https://codex.wordpress.org/Class_Reference/Walker and here: https://developer.wordpress.org/reference/classes/walker_nav_menu/ Hope that helps.

Add custom attribute to menu item link using Filter

You may target the current_page_item CSS class or you may target the current-menu-item CSS class instead. current_page_item class may not be present for all kinds of menu item. Read the answer here to know why. Whichever CSS class you choose, you may use the CODE like the following to set the attribute: add_filter( ‘nav_menu_link_attributes’, ‘wpse260933_menu_atts_filter’, … Read more

wp_nav_menu() doesn’t apply correctly classes and IDs to menu and container

I believe this is caused probably by your theme or another plugin, filtering on wp_nav_menu_args and changing the items_wrap value. I tested your provided code and the output was correct, using blank WordPress 4.9.4 installation. You could try passing items_wrap with default value: wp_nav_menu( [ ‘menu’ => ‘Primary Navigation’, ‘menu_class’ => ‘this-is-the-menu-class’, ‘menu_id’ => ‘this-is-the-menu-id’, … Read more

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