On the backside of my web page I’m attempting to show some latest tasks based mostly on a pre-selected checklist of publish IDs.
I’ve constructed a customized question to try to retrieve the three particular posts (WHERE custom_post_type = undertaking) on the backside of my web page
$projectIDs = array( [0] => 79, [1] => 98, [2] => 108 );
$args = array( 'post_type' => 'tasks', 'post__in ' => $projectIDs, 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
whereas ( $loop->have_posts() ) : $loop->the_post();
endwhile;
PROBLEM: It’s returning 3 fully completely different posts: 110, 108, 111 – Did not even return certainly one of them. I can see within the question it filters the post_type however there isn’t any filter for the post__in …
I do not play with WP Question a lot so undecided if I am even calling it accurately BUT, once I analyse the outcomes var_dump($loop)
I see the posts aren’t even being queried:
object(WP_Query)#9671 (49) {
["query"]=>
array(3) {
["post_type"]=>
string(8) "tasks"
["post__in "]=>
array(3) {
[0]=>
int(79)
[1]=>
int(98)
[2]=>
int(108)
}
["posts_per_page"]=>
int(3)
}
["query_vars"]=>
array(65) {
["post_type"]=>
string(8) "tasks"
["post__in "]=>
array(3) {
[0]=>
int(79)
[1]=>
int(98)
[2]=>
int(108)
}
["posts_per_page"]=>
int(3)
...
["request"]=>
string(276) "SELECT SQL_CALC_FOUND_ROWS wpKX_posts.ID FROM wpKX_posts WHERE 1=1 AND wpKX_posts.post_type = 'tasks' AND (wpKX_posts.post_status = 'publish' OR wpKX_posts.post_status = 'acf-disabled' OR wpKX_posts.post_status = 'personal') ORDER BY wpKX_posts.post_date DESC LIMIT 0, 3"
["posts"]=>
array(3) {
[0]=>
object(WP_Post)#9663 (24) {
["ID"]=>
int(110)
...
}
[1]=>
object(WP_Post)#9603 (24) {
["ID"]=>
int(108)
...
}
[2]=>
object(WP_Post)#9602 (24) {
["ID"]=>
int(111)
...
}
}
["post_count"]=>
int(3)
What am I doing flawed?