Support » Fixing WordPress » Access current logged in user from loop

  • Resolved BigJohn

    (@bigjohn)


    Looking for a way to display current logged in user posts, ie how do I identify him in the loop so that I can display his posts?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You mean when an user is logged in you want to display their post, and only their posts, to them?

    If so, using query_posts() to initialize The Loop as shown below should get you started:

    <?php
    global $user_ID;
    get_currentuserinfo();
    if($user_ID) {
    query_posts("author=$user_ID");
    }
    ?>

    EDIT: Stuck an if statement in for a bit of sanity.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Access current logged in user from loop’ is closed to new replies.