Title: Show &#8220;My Posts&#8221;
Last modified: August 19, 2016

---

# Show “My Posts”

 *  [levani01](https://wordpress.org/support/users/levani01/)
 * (@levani01)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/show-my-posts/)
 * Can anyone tell my why this code doesn’t work?
 *     ```
       <?php  if (is_user_logged_in()){
                  global $current_user;
                  get_currentuserinfo();
        query_posts('author_name = $current_user->user_login');
        }
       else {
                  echo "Please register!";
                  };
       ?>
       ```
   
 * It retrieves all posts, but not only current user’s posts.
 * Anyone can help?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/show-my-posts/#post-962381)
 * It seems author_name needs to be assigned the user_nicename according to the 
   [Author parameters section of query_posts](http://codex.wordpress.org/Template_Tags/query_posts#Author_Parameters).
 * If not see if this works instead:
    `author=$current_user->ID`
 * Related
    [Author_Templates](http://codex.wordpress.org/Author_Templates)
 *  Thread Starter [levani01](https://wordpress.org/support/users/levani01/)
 * (@levani01)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/show-my-posts/#post-962594)
 * It doesn’t work 🙁
 * Neither author_name=$current_user->user_login nor author=$current_user->ID.
 * <?php echo author=$current_user->ID; ?> writes the ID of the current user but
   the above code still doesn’t work.
 * Any ideas?

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

The topic ‘Show “My Posts”’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [levani01](https://wordpress.org/support/users/levani01/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/show-my-posts/#post-962594)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
