Title: Read Authors/other into PHP variable
Last modified: August 19, 2016

---

# Read Authors/other into PHP variable

 *  Resolved [barelytone](https://wordpress.org/support/users/barelytone/)
 * (@barelytone)
 * [17 years ago](https://wordpress.org/support/topic/read-authorsother-into-php-variable/)
 * Hi, I’m a first time theme developer, and making a theme for a client to use 
   more as an online journal than as a blog.
 * Specifically, I’m wondering if there are ways to read the list of authors / topics
   etc. into a php array variable. I do this because I display a list of Authors,
   but like to exclude a specific subset of authors from that list.
 * The way I’m currently solving the problem is to read wp_list_authors() into a
   string, hash it up with PHP’s explode function, and then get the authors using
   preg_match(). Its a rather unelegant solution, and depends on a specific wp-admin
   configuration (i.e. permalinks have to be set right, etc.).
 * Initially, I tried a direct MySQL query, but that only seemed to mess up “the
   loop” as other information from $wp_query was corrupted.
 * Can someone point me in the right direction here?
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/read-authorsother-into-php-variable/#post-1089111)
 * This little routine has some ideas you might use:
 *     ```
       <?php
       //get all users, iterate through users, query for one post for the user, if there is a post then display posts title, author, content info
       $blogusers = get_users_of_blog();
       if ($blogusers) {
         foreach ($blogusers as $bloguser) {
           $args = array(
           'author' => $bloguser->user_id,
       	  'showposts' => 1,
       	  'caller_get_posts' => 1
           );
           $my_query = new WP_Query($args);
           if( $my_query->have_posts() ) {
             // $user = get_userdata($bloguser->user_id);
             // echo 'This is one post for author with User ID: ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname;
             while ($my_query->have_posts()) : $my_query->the_post(); ?>
               <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
               <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?> </small><?php
               the_content();
             endwhile;
           }
         }
       }
       ?>
       ```
   
 *  Thread Starter [barelytone](https://wordpress.org/support/users/barelytone/)
 * (@barelytone)
 * [17 years ago](https://wordpress.org/support/topic/read-authorsother-into-php-variable/#post-1089128)
 * That’s very helpful thank you. I think this will certainly point me in the direction
   I’ve been thinking of.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Read Authors/other into PHP variable’ is closed to new replies.

## Tags

 * [author](https://wordpress.org/support/topic-tag/author/)
 * [lists](https://wordpress.org/support/topic-tag/lists/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [barelytone](https://wordpress.org/support/users/barelytone/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/read-authorsother-into-php-variable/#post-1089128)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
