I want to display a single post by its ID using WP_Query(). To do this, I use the following argument:

$args = array(
   'p' => 61202);

That should work, but does not seem to work if the post is in a custom post_status.

To fix this, I tried the following:

$args = array(
   'p' => 61202, // id of post
   'post_type' => 'any', // apply to all post types
   'post_status' => 'my_custom_status' // the custom post status
);

But this still does not work. Why?!

Is there a known bug? I am running this code in the wp-admin area. It works fine if the post is in any of the WP core post statuses.

Read more here: WP_Query by post ID doesn’t work if post is in custom post_status


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: