wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

Display top 8 authors in wp_nav_menu using wp_list_authors

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will add an authors item to your wp_nav_menu listing top eight authors by post count.

snippet :  PHPcopy
function wps_nav_authors($items, $args){
    if( $args->theme_location == 'header-navigation' )
        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);

Did you like this post? If so please share it with your friends. Thanks!