Updating this conditional secondary navigation snippet

Community Forums Forums General Discussion Updating this conditional secondary navigation snippet

This topic is: not resolved

This topic contains 2 replies, has 3 voices, and was last updated by  joyv 10 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #74103

    ameeker
    Participant
    Post count: 29

    http://ahjira.com/create-a-conditional-secondary-menu-for-genesis-child-themes

    The snippet below is from the post above, which details how to use the custom menus to show top-level items in the Primary nav location and their conditional sub-menu items in the Secondary. The article does reference that it’s out of date since 2.0. I tried it on a new installation using the Sample Child Theme, and the primary nav disappeared. Wondered if anyone is around who could take a look and see what, if anything, needs to be updated in it for 2.0? Will be brilliant if it works.

    add_filter( 'genesis_do_nav', 'ahjira_nav_args', 10, 3 );
    
    function ahjira_nav_args( $nav_output, $nav, $args ) {
      if( $args['theme_location'] == 'primary' ) {
        $args['depth'] = 1;
      }
      $nav = wp_nav_menu($args);
      $pattern = genesis_markup( '<nav class="primary">%2$s%1$s%3$s</nav>', '<div id="nav">%2$s%1$s%3$s</div>', 0 );
    	$nav_output = sprintf( $pattern, $nav, genesis_structural_wrap( 'nav', 'open', 0 ), genesis_structural_wrap( 'nav', 'close', 0 ) );
      return $nav_output;
    }
    #74784

    cdils
    Participant
    Post count: 421

    This may not be the fix, but looking at the markup in 2.0, there are some differences.
    Note the class of “nav-primary” on <nav> and the id/classes on the <ul> tag.

    Here’s an HTML excerpt from the Genesis demo (http://my.studiopress.com/themes/genesis/#demo-full)

    <nav class="nav-primary" itemtype="http://schema.org/SiteNavigationElement" itemscope="itemscope" role="navigation">
    <div class="wrap">
    <ul id="menu-secondary-navigation" class="menu genesis-nav-menu menu-primary">

    Have you been helped in this forum? Pay it forward and answer someone else’s question. I bet you’ll know the answer to at least one question. :)

    I host a weekly Genesis-focused podcast called Genesis Office Hours. I tweet @cdils.

    #84109

    joyv
    Participant
    Post count: 12

    I would also love to know how to make this work if anyone could help.

    ameeker, did you find a solution?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.