remove menu items if user can’t read
This was asked here a couple of years ago. Display navigation menu item conditionally based on user capabilities There are several options there that would work.
This was asked here a couple of years ago. Display navigation menu item conditionally based on user capabilities There are several options there that would work.
/** * Changes Label of Admin Menu items * @global array $menu * @global array $submenu */ function change_post_menu_label() { global $menu; global $submenu; $menu[2][0] = ‘Home’; $menu[5][0] = ‘Articles’; $submenu[‘edit.php’][5][0] = “All Articles”; // var_dump($submenu); // var_dump($menu); echo ”; } if(!is_super_admin()){ add_action( ‘admin_menu’, ‘change_post_menu_label’ ); } You can print the array echo “<pre>”; print_r($menu); … Read more
if (is_single()) { // DONT SHOW MENUS } you may pass a post id for any specific post for eg – if (is_single(‘4’)) { // DONT SHOW MENUS } will execute on post with id = 4 . hope it helps
Ok based on what I think you want from your description, you can accomplish this via CSS. You don’t need to create a custom walker for this unless you have other reasons to do so. If you look carefully, when a menu item is active it will apply the following CSS to the “li” element … Read more
As you din’t post any live site with the example of menu, so if I don’t get you wrong, then a nice dropdown menu like this: +——–+——–+——–+ | Menu 1 | Menu 2 | Menu 3 | +——–+——–+——–+ | Sub Menu 1 | +————+ | Sub Menu 2 | +————+ can be attained easily by … Read more
You already hinted it yourself: When you look at wp_get_nav_menu_items() you’ll see that the resulting Array of items gets mapped over with wp_setup_nav_menu_item() – in other words, this function gets applied to each and every nav menu item. In there you can hook into the ‘wp_setup_nav_menu_item’-filter with its $menu_item argument, or use one of the … Read more
By specifying a theme_location argument in my array, the issue was fixed: wp_nav_menu(array( ‘theme_location’ => ‘main_menu’ )); Edit For a distributed Theme, do not pass the ‘menu’ parameter to the wp_nav_menu() call. It will look for a specific slug of a user-created menu, and will override ‘theme_location’. Only ever pass ‘theme_location’.
In Appearance ยป Menus, is you are using WordPress 3.7+, then from the left, under Links area, put your URL and then name the link. If you don’t want to link the menu to any physical link, then just put a hash (#) there.
You need a Custom Walker for this. In your Custom Walker you define the start of the element different, adding a span after the link: class Walker_With_Title_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $output .= sprintf( “\n<li><a href=”https://wordpress.stackexchange.com/questions/131521/%s”%s>%s</a><span class=”your-line”>%s</span></li>\n”, $item->url, ( $item->object_id === … Read more
You are applying that filter to every query on the pages matching the conditions or that if. You need to restrict this to only the main query and make sure that the conditions are only operating on the $q query passed into the function. if ($q->is_main_query() && $q->is_post_type_archive(‘inspiration’) && !is_admin()) {