Support » Fixing WordPress » Only include author-role in my user-listing script

  • Hello,

    The snippet at the end of this post is perfect for what i want, except one thing: it includes all roles. So this is what i am doing. I am listing all the authors with a number displaying how many post they have published, and a link to their latest post. Their name links to an overview over all the posts. The problem is that i would like to display ONLY one role, the author-role, but currently every user in wordpress get listed (admins, editors, authors, subscribers). How can i exclude the roles i do not want?


    <div class="authorsContainer">
                    //define vars from user selection
                    $howManyAuthors = 50;
                    //Get users and count of posts put into array
                    $blogusers = get_users_of_blog();
                    if ($blogusers) {
                      foreach ($blogusers as $bloguser) {
                        $post_count = get_usernumposts($bloguser->user_id);
                      $maxauthor = $howManyAuthors;
                      foreach ($authorsArray as $key => $value) {
                        if ($count <= $maxauthor) {
                            $user = get_userdata($key);
                            $username = $user->user_login;
                            $displayname = $user->display_name;
                            $author_posts_url = get_author_posts_url($key);
                            $post_count = $value;
                        <div class="topWriterBox">
                            <div class="topWriterName">
      <div class="topWriterArticles"><?php echo __('', '').$post_count.__('', ''); ?></div>                            
    <a href="<?php echo $author_posts_url; ?>"><?php echo $displayname; ?> </a>
                              $my_query = new WP_Query($args);
                              if( $my_query->have_posts() ) {
                                while ($my_query->have_posts()) : $my_query->the_post();
                            <!--============ THE AUTHORS ARTICLE DATA ================-->
                                <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permenent Link To <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <small>(<?php the_time('m.d.y') ?></small>)</li>  
                        </div><!-- end of topWriterBox -->
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Only include author-role in my user-listing script’ is closed to new replies.