1

My WP query to fetch some custom posts should exclude private posts, but this query is returning all posts, not just public ones:

$wp_query = new WP_Query( 'post_type=listing&post_status!=private&posts_per_page=9&meta_key=location_level1_value&orderby=location_level1_value&order=ASC&paged='.$paged);

I've also tried using post_status=-private, but that didn't work either...

What have I done wrong?

2

I have to wonder if post_status=public would successfully exclude. That way it's just targeting the public posts.

  • It does, except then I also include empty "Auto Draft" posts – Amanda Oct 18 '10 at 23:07
  • 1
    But post_status=publish does the trick... thanks – Amanda Oct 18 '10 at 23:14
  • 2
    Except that post_status=publish WILL include private posts if the user happens to be logged in. – David Jan 16 '13 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.