0

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?

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.