Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End How to check if a menu item is assigned to a menu location

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #239052
    Ayanize
    Participant

    Hi,

    I wish to show an admin notice to users if my theme made menu name is not selected. So for me, the menu name is My Theme Menu (slug my-theme-menu) and the location is primary-menu.

    function show_notice(){
    
    //check if the menu My Theme Menu is selected to primary menu or not
    }
    add_action('admin_notices', 'show_notice');
    
    #239108
    Ilan Firsov
    Participant

    I think you can use wp_get_nav_menu_items(). As far as I can tell it returns false when the menu does not exist and empty array if the menu doesn’t have any items in it.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.