Menu Disappears on Category Pages

I know this is an old question but seems that is still unresolved. As @Milo said you may have an incorrect pre_get_posts implementation. Most people do this like this (example): add_filter( ‘pre_get_posts’, ‘query_post_type’ ); function query_post_type( $query ) { if ( is_category() ) { $post_type = get_query_var( ‘post_type’ ); if ( $post_type ) { $post_type … Read more

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

Why is my menu order not working with wp_nav_menu?

AFAIK there’s a non-documented orderby parameter, that can be set to menu_order. Edit: Straight from core, inside /wp-includes/nav-menu-template.php Line# 195 (WP 3.3.1): $sorted_menu_items = array(); foreach ( (array) $menu_items as $key => $menu_item ) $sorted_menu_items[$menu_item->menu_order] = $menu_item; It’s the lines immediately before the Walker runs. So the set menu_order should affect the order. You’ll just … Read more

How to add post count to wp_nav_menu?

Basically the easiest thing should be a callback to the start_el() method of the Walker class. // From core: apply_filters( ‘walker_nav_menu_start_el’, $item_output, $item, $depth, $args ); Just grab the data (whatever the actual data is and from wherever it comes) and append it. add_action( ‘walker_nav_menu_start_el’, ‘wpse_10042_nav_menu_post_count’, 10, 4 ); function wpse_10042_nav_menu_post_count( $output, $item, $depth, $args … 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

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