WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a way to return something like the following:

  • User, email, post title, post status
  • User, email, post title, post status
  • repeated....

Each user on my site has only 1 post. It is a custom post type called Company Listing.

share|improve this question
up vote 4 down vote accepted

You can do that with a simple loop assuming that the users are also the authors of the post, create a template page, and copy the inside of your page.php to it.

then replace the loop part with this code:

$args = array(
    'post_type' => 'company-listing', //change this to your actual CPT name
    'posts_per_page' => -1, //-1 to get all or any number you want to use with pagination
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
User, email, post title, post status
    <div class="post company-listing">
<?php  $user_info = get_userdata($post->post_author); ?>
        <li class="user">
            <?php echo $user_info->user_nicename; ?>
        <li class="email">
            <?php echo $user_info->user_email; ?>
        <li class="title">
            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
        <li class="status">
            <?php echo $post->post_status; ?>
<div style="clear:both"></div>

<?php endwhile; ?>

    <?php else: ?>

        <p class="no-data">
            <?php _e('Sorry, no page matched your criteria.'); ?>
        </p><!-- .no-data -->
 <?php endif; ?>

and add this little code css to style it right:

<style type="text/css">
company-listing ul li{ float: left;padding: 2px;}

now you didn't specify what is "USER" so i just showed you how to use user_nicename but after this line $user_info = get_userdata($post->post_author); you can use $user_info with:

  • user_firstname
  • user_lastname
  • ID
  • user_login
  • user_pass
  • user_nicename
  • user_email
  • user_url
  • user_registered
  • display_name

and a few more.

As for status i assume you are talking about the post_status so you will need to add 'post_status' => array('publish','pending','draft','future','private',....) to your $args.

and if you are talking about a custom filed then just call that field with get_post_meta($post->ID,'status_field_name',true);

Hope this helps

share|improve this answer
If limit the number of posts and use pagination, the same post load on each page. Is there something here that is making that happen? – Carson Apr 14 '11 at 21:40
yeah you would need to add $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; and then to your $args array 'paged' => $paged; – Bainternet Apr 15 '11 at 0:48
Thanks Bainternet – Carson Apr 16 '11 at 15:59
Glad i could help – Bainternet Apr 16 '11 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.