Title: Display Posts by Specific User
Last modified: August 19, 2016

---

# Display Posts by Specific User

 *  [roback](https://wordpress.org/support/users/roback/)
 * (@roback)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/)
 * I would like to show the posts of the current logged in user on the front end
   profile page. (I have used Theme My Profile plugin to have user profiles diplayed
   on the front end of my site.
 * it is the page they are taken to upon logging in each time.
 * On that page, I want to show a list of the posts attached to that specific user.
 * I am speculating here, but to be logged in would mean there is a check/validation
   and probably your user ID already retrieved and stored some where. So all I probably
   need is a call to show the posts by the logged in user.
 * Any ideas on how to do/code this?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/#post-1739665)
 * You could start with [get_currentuserinfo](http://codex.wordpress.org/Function_Reference/get_currentuserinfo)
 *  [chneijens](https://wordpress.org/support/users/chneijens/)
 * (@chneijens)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/#post-1739677)
 * put this in the php
 * global $current_user;
    $current_user = wp_get_current_user();
 * from here, you can use $current_user->ID where you want.
 * then create the wordpress query(please see [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
   for more information)
 * example
    query_posts(‘author=$current_user->ID&post_type=post’);
 *  Thread Starter [roback](https://wordpress.org/support/users/roback/)
 * (@roback)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/#post-1739716)
 * Okay, this is what I used to get the user info:
 *     ```
       global $current_user;
             get_currentuserinfo();
   
             echo '<div style="padding:10px;">';
       	  echo 'Username: ' . $current_user->user_login . "<br>";
             echo 'User email: ' . $current_user->user_email . "<br>";
             echo 'User first name: ' . $current_user->user_firstname . "<br>";
             echo 'User last name: ' . $current_user->user_lastname . "<br>";
             echo 'User display name: ' . $current_user->display_name . "<br>";
             echo 'User ID: ' . $current_user->ID . "<br>";
       	  echo '</div>';
       ```
   
 * most of that is just to display for testing purposes, but it displays the current
   user correctly.
 * Then I use this to get the query:
    `query_posts('author=$current_user->ID');`
 * And then I used this loop to try to display things (keyword try!)
 *     ```
       <?php //The Loop
       							if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       							 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                                    <p> <?php the_author('author=$current_user->ID') ?> </p>
       							<?php endwhile; else: ?>
       							 ..
       							<?php endif; ?>
       ```
   
 * The problem that arises is that it doesn’t display posts from that author it 
   displays posts from any author and the most recent posts.
 * is there something wrong in what I am doing? Is the $current_user not being carried
   into the Loop?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/#post-1739722)
 * Try `query_posts('author=' . $current_user->ID);`

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

The topic ‘Display Posts by Specific User’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [15 years, 7 months ago](https://wordpress.org/support/topic/display-posts-by-specific-user/#post-1739722)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
