Home / author / Display top 8 authors in wp_nav_menu using wp_list_authors
  • How to Display top 8 authors in wp_nav_menu using wp_list_authors

    display-top-8-authors-in-wp_nav_menu-using-wp_list_wuthors

    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.

    wordpress snippet : PHP

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

    ( WordPress codex functions, hooks, in this snippet. )

    add_filter, wp_nav_menu, _n, wp,