Support » Fixing WordPress » Creating a dropdown in menu that lists authors

  • Resolved RaiderKat

    (@raiderkat)


    Hi, I was wondering if anyone knows if there is a way to create a menu item in the main menu that would have a dropdown list of authors?

    I’m trying to add a menu item that would automatically update new contributors as we add them?

    I’ve been looking everywhere and cant seem to figure out a way to do it.

    Thanks so much!

Viewing 15 replies - 1 through 15 (of 45 total)
  • Thanks for the response. I think that is kind of what i’m looking for but i want to add the dropdown list to the main navigation menu so it would be like this: (you click on contributor and the drop down menu appears)
    Home Contributors About Contact
    drop down menu

    I’m not sure how to add that functionality as the WordPress “Menus” only gives posts, pages and categories??

    Thanks again!

    It is possible but you would need to know some javascript, html and css.
    There are many ways to do this as in any type of coding project but what I would do is use the javascirpt to stop the anchor of contributors from leaving the page then have it fade in or make the the dropdown menu appear instantly. In the template you would add wp_get_author(array('name' => 'author')); in the same div or element that holds the nav. In the css you would have to make the div or element that holds the nav position relative, then make the dropdown position absolute and position it to be under the contributors link with top and left or right and display:none.

    The HTML and the CSS I can handle, not sure if i can figure out the javascript code. Havent used javascript in forever! But thank you that was very helpful! I’ll see if I can figure out the javascript code to use!

    Thanks so much for your help!

    So i found a few other things and played around with them, 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);

    it actually seems to be working great except..for some reason, it makes my second menu disappear.

    I have two menus on my page, one at the top named top_menu and the main navigate(where i want to put the authors named main_menu. Any idea why it would make my top menu disappear? The container is still there, but the links have disappeared.

    Thanks so much for your help. You definitely put me in the right direction!

    post a link to your site/page.

    Welcome to FAV

    If you look up at the top there should be a menu with the Home, about and contact buttons..but they disappear when i put that code in

    remove the code really fast and let me see the secondary nav

    Done

    ok put it back

    k done

    Try this

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

    No..still not working..so odd! Should only effect the Primary menu..

    Ok one more

    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&orderby=post_count&order=DESC&number=8&echo=0') . '</li></ul></li>';
        }
        return $items;
    }

    Parse error: syntax error, unexpected ‘}’ in /home2/ksamoun/public_html/wp-content/themes/twentyeleven/functions.php on line 2920

Viewing 15 replies - 1 through 15 (of 45 total)
  • The topic ‘Creating a dropdown in menu that lists authors’ is closed to new replies.