Strange menu behaviour wordpress admin [duplicate]

This is an issue with google chrome, i think the devs are working on a core fix but in the mean time you can add this to your functions.php and it should do the trick: add_action( ‘admin_enqueue_scripts’, ‘chrome_fix’ ); function chrome_fix() { if ( strpos( $_SERVER[ ‘HTTP_USER_AGENT’ ], ‘Chrome’ ) !== false ) { wp_add_inline_style( … Read more

wp_nav_menu_items for one menu

I came across your question by looking for an answer myself. Here is how I made the code work for me: function new_nav_menu_items( $items, $args ) { if ( $args->menu == ‘primary’ ) { $items = “”; $args = array( “post_type” => “page”, “order” => “ASC”, “orderby” => “menu_order” ); $the_query = new WP_Query( $args … Read more

Current author archive in navigation menu

Finally I figured it out and I am posting the solution for anyone who may be interested in such a workaround: function my_nav_menu_author_link( $menu ) { if( !is_user_logged_in() ){ return $menu; } else { $link = get_author_posts_url( get_current_user_id() ); $class = is_author() ? ‘ class=”current-menu-item”‘ : ”; $author_archive_link = ‘<li’ . $class . ‘>’ . … Read more

WordPress functions.php does not affect the theme menus

Try with adding this code into header.php, where menu usually appears. In functions.php you can declare custom menus, but you are calling them in header.php or wherever you want menus to appear. Function register_nav_menus() declares menus and should go into functions.php, while wp_nav_menu() outputs menus you declared anywhere on the page (so not inside functions.php).

Adding archive years to my menu

Hi Please follow below code do add dynamically year wise post under sub menu you want, I have added below code in functions.php add_filter( ‘wp_nav_menu_objects’, ‘ravs_add_menu_parent_class’ ); function ravs_add_menu_parent_class( $items ) { foreach ( $items as $item ) { //print_r($item);//print each menu item an get your parent menu item-id // get your menu item ID … Read more

Show different menu on each woocommerce category page

This is the solution I found that works: As usual in these cases, override the archive product template from your woocommerce plugin folder by copying archive-product.php to yourtheme/woocommerce/archive-product.php. Edit the file, and add this code at the beginning (or wherever the menu needs to show up): <?php if ( is_tax( ‘product_cat’, ‘cat1’ )) { wp_nav_menu( … Read more