Support » Fixing WordPress » Get posts from a specific user.

  • Resolved cip6791

    (@cip6791)


    Hello,

    I am trying to get the posts from a logged in user.

    This code displays the user that is logged in and the user id.

    if ( is_user_logged_in() ) {
    
    global $current_user;
          get_currentuserinfo();
    
        echo 'Welcome, registered user!';
    echo 'User ID: ' . $current_user->ID . "\n";
    } else {
        echo 'Welcome, visitor!';
    };

    Welcome, registered user!User ID: 1

    How can I get all the posts that the user with the ID:1 has posted?
    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get posts from a specific user.’ is closed to new replies.