php - WP_Query 'post__not_in' condition is not working: shows all posts
one text
thank you for taking the time to review this.
I am calling a new WP_Query with the following arguments:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'post__not_in' => array($featured_post_ID),
'category_name' => 'blog',
'offset' => $offset,
'posts_per_page' => 3,
'orderby' => 'post-date',
'order' => 'DESC',
);
I know that past issues have been caused by passing a numeric post ID as a variable instead of string; to get around that I am using the following variable definition for $featured_post_ID
:
$featured_post_ID = '"'.$post_ID.'"';
When I run this query, it outputs the post I am trying to exclude.
Here is a Transcript of output of the WP_Query to save space. Looks like post__not_in
is recognized in the query, but has no effect on the output.
Can anyone advise why this might be happening, or how to fix it?
Source