• <?php wp_nav_menu( array( ‘theme_location’ => ‘sports-menu’ ) ); ?>

    Is what to pull specific menus in that location on the pages i assigned.

    However what is the proper if tag to ignore if page or homepage doesnt have menu in that location on specific page?

    I have tried

    <?php if ( has_nav_menu( ‘sports-menu’ ) ) : ?>
    <?php wp_nav_menu( array( ‘theme_location’ => ‘sports-menu’ ) ); ?>
    <?php endif; ?>

    It thrown the WP off and wont even show at all. What is the right way to write? Thanks!

Viewing 1 replies (of 1 total)
  • I think you are confused, as I am/was, about what a ‘theme location’ is.

    A theme location designates a visual container/space in your theme that is identified by the theme_location slug.

    Whether that theme location (and the menu belonging to it) is actually used in your theme files (such as home.php) depends entirely on the theme code.

    If you don’t want it to show on a specific page or on a specific category or whatever, you need to modify the php code in those templates so as to not show that menu.

    But it appears as if you are trying to WRITE a theme? And you want the menu to hide if the user has not assigned a menu to that location?

    That’s the only way it makes sense to me. But I do not have a theme with Menu support, so I can’t see what exactly you mean or how it would work. You will have to be more clear on what you want and what you are exactly doing.

    Also, I don’t know what you mean by “It thrown the WP off and wont even show at all.”

    In any case, such a menu is defined (registered) with a global theme_location slug and it has nothing to do with pages.

Viewing 1 replies (of 1 total)
  • The topic ‘wp_nav_menu help…’ is closed to new replies.