WordPress.org

Ready to get started?Download WordPress

Forums

Getting private post from outside WP (2 posts)

  1. Ry99
    Member
    Posted 5 years ago #

    I need to get a private post from outside of WordPress. It works fine with a public post, but not private. Here's the code:

    $query = "p=" . SURVEY_POST_ID;
    	$wp_query->query($query);

    That works exactly how I would like with public posts. I can get the private post using:

    $thisPost = get_post($id = 1);

    but then comments don't work (and that's all I really need, I don't even need the post info, just to add and view its comments). So, I either need the first code block to work getting a private post, or I need the second one to setup everything so that comments will work. Please point me in the right direction. Thanks a million!

  2. MichaelH
    Member
    Posted 5 years ago #

    What happens if you add 'post_status=private' to your parameters?

    $query = "post_status=private&p=" . SURVEY_POST_ID;

Topic Closed

This topic has been closed to new replies.

About this Topic