Hide pages from the main menu

Instead of writing custom styles like .menu-item-346 where you are hardcoding some styles… why not just add a custom css class with the editor under Appearance -> Menus. WordPress has this build in. Under Appearance -> Menus you need to open the Screen Options and tick the box CSS Classes. After this you can now … Read more

Hide an item from a menu to some users

Pls use filter wp_nav_menu_{$menu->slug}_items for conditionally adding or removing the menu-items. https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/ See Method 2 at: https://wordpress.stackexchange.com/a/31753/116231

how do i develop a global nav and local nav to be wordpress dynamic?

WordPress calls these Navigation Menus. There are a few steps: Set up a child theme, if you aren’t already using one. That way your changes won’t be lost when the main theme is updated. Register the menu – in your child theme’s functions.php file, function mythemeslug_register_custom_menu() { register_nav_menu(‘topnav’, __(‘Top Nav’)); } add_action(‘init’, ‘mythemeslug_register_custom_menu’); Call the … Read more

Twenty Fifteen: Change navigation menu behavior

In case anyone is interested, I think I managed to find a solution. Just had to add the following two lines of code just after the e.preventDefault(); line and before the _this.toggleClass( ‘toggle-on’ ); one: container.find( ‘.dropdown-toggle.toggle-on’ ).not( _this ).not( _this.parents( ‘.children, .sub-menu’ ).prev( ‘.dropdown-toggle’ ) ).removeClass( ‘toggle-on’ ).attr( ‘aria-expanded’, false ); container.find( ‘.children.toggled-on, .sub-menu.toggled-on’ … Read more

Notice: Trying to get property of non-object

This code tries to retrieve a post instance, but it is failing for some reason. On top of my head I don’t think this should ever happen within normal operation of menus. I would suspect that menu structure is somehow corrupt. Without diving into development side of it, an attempt of easy fix might be … Read more

Static site menu with multiple ul’s to wp menu

The html you give is standard WordPress behaviour, even including the wrapping <div>. Additionally you can pass parameters to wp_nav_menu to better suit your needs. The following should replicate your html: $args = array( ‘theme_location’ => ”, ‘menu’ => ”, ‘container’ => ‘div’, ‘container_class’ => ‘nav-menu’, ‘container_id’ => ”, ‘menu_class’ => ‘nav-container’, ‘menu_id’ => ”, … Read more

Make two bootstrap menus collapse into one dropdown

I had the same problem, the solution is quite simple. Add to your menus arrays such thing: to the left menu ‘container_id’ => ‘navbarNavDropdown-left’, to the right menu ‘container_id’ => ‘navbarNavDropdown-right’, And you have just change your data-target to: data-target=”#navbarNavDropdown-left,#navbarNavDropdown-right”

Custom menu walker – remove li tag based on class name

Do you have error logging on? If you’re running the latest version of WP, this should be throwing an error because start_el and end_el are public functions. Also, if you’re using a custom walker, you should only use the walker and not your additional theme_function. class wpseWalker extends Walker_Nav_Menu { public function start_el(&$output, $item, $depth … Read more

How to hide the menu item created by the theme in WordPress admin panel?

As a temporary solution, add below script to the function.php file wp_enqueue_style( ‘flatsome-hide’, get_stylesheet_directory_uri() . ‘/css/flatsome.css’, array(‘flatsome’), ‘1.0’ ); Crete a CSS file called “flatsome” inside your CSS directory, or whatever you prefer, make sure you update the name and the path on function.php. Then inspect the menu class and hide it using display: none … Read more