X

Display top 8 authors in wp_nav_menu using wp_list_authors

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.



Code Snippet:


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

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!