• Resolved RaiderKat

    (@raiderkat)


    Hi, I am trying to implement a menu item to list authors. The code i came up with works GREAT..only one issue! I have two nav menus registered, Primary and Secondary.

    When I add the code to my page, targeting the primary menu, the secondary menu disappears. The box is still there but all the links are gone.

    Any ideas why?? here is the code I’m using:

    function wps_nav_authors($items, $args){
    
        if( $args->theme_location == 'primary' )
    
            return $items . '<li><a href="#">Authors</a><ul class="sub-menu"><li>' . wp_list_authors('show_fullname=1&optioncount=0&orderby=post_count&order=DESC&number=8&echo=0') . '</li></ul></li>';
    
    }
    
    add_filter('wp_nav_menu_items','wps_nav_authors', 10, 2);

    Thanks so much for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would view source on the page
    that should help you figure out whats happening
    If the data is there
    or if its not executing

    Thread Starter RaiderKat

    (@raiderkat)

    when i have the code in there all that shows up for the secondary menu is this
    <div class="menu-top_menu-container"><ul id="menu-top_menu" class="menu"></ul></div>

    no list

    The primary menu works fine, and the authors are added to the menu

    If i take the code back out..they both work

    Thread Starter RaiderKat

    (@raiderkat)

    For anyone who is looking, I figured I would post the solution! Here is the code that works! Happy Coding!

    add_filter( 'wp_nav_menu_items', 'wps_nav_authors', 10, 2 );
    function wps_nav_authors ( $items, $args ) {
        if ( $args->theme_location == 'primary') {
            $items .= '<li><a href="#">Authors</a><ul class="sub-menu"><li>' . wp_list_authors('show_fullname=1&optioncount=0&exclude_admin=0&orderby=post_count&order=DESC&number=8&echo=0') . '</li></ul></li>';
        }
        return $items;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with wp_list_authors’ is closed to new replies.