admin管理员组

文章数量:1332394

I use Divi plugin.

I have these menu items:

  • Blog
  • Enterprise
  • Coach
  • Help

On my home page, I have these 4 items: OK When I click on "Entreprise" item (to show enterprise page), I want to hide automatically "Blog" item into toolbar menu. And of course if I come back on home page, I want to show "Blog" item.

How can I do that please?

I use Divi plugin.

I have these menu items:

  • Blog
  • Enterprise
  • Coach
  • Help

On my home page, I have these 4 items: OK When I click on "Entreprise" item (to show enterprise page), I want to hide automatically "Blog" item into toolbar menu. And of course if I come back on home page, I want to show "Blog" item.

How can I do that please?

Share Improve this question asked Jul 9, 2020 at 4:57 AnthonyAnthony 101
Add a comment  | 

1 Answer 1

Reset to default 1

Add this code to your functions.php:

function hide_menu_items( $items ) {
    if ( is_page( 'Enterprise' ) ) { // You can use page ID, slug or title here
        foreach ($items as $key => $item) if ( $item->title == "Blog" ) unset( $items[$key] );
    }
    return $items;
}
add_filter( 'wp_get_nav_menu_items', 'hide_menu_items', 20 );

本文标签: customizationDivi how to hideshow specific menu according current page