WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Access current logged in user from loop (3 posts)

  1. BigJohn
    Member
    Posted 8 years ago #

    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

  2. Kafkaesqui

    Posted 8 years ago #

    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.

  3. BigJohn
    Member
    Posted 8 years ago #

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags