On a seperate note, 'caller_get_posts'
was deprecated in version 3.1 – use 'ignore_sticky_posts'
with a boolean argument instead.
'exclude'
is not a query argument so WordPress ignores it. Post exclusion via query is done using the key 'post__not_in'
with a single post ID or array of IDs instead. However as @vancoder points out, the argument produces computationally expensive queries.
It’s also unreasonable to apply both a 'post__in'
argument as well as a 'post__not_in'
argument as setting one implicitly describes the value of the other. A simpler and more efficient solution is available whenever you might desire to use both: just exclude post IDs from the 'post__in'
argument before applying it to the query:
$included_post_ids = $wpdb->get_col( /* ... */ );
$excluded_post_ids = [ /* ids to exclude */ ];
if( !empty( $included_post_ids ) ) {
$included_post_ids = array_diff( $included_post_ids, $excluded_post_ids );
$args = [
'post__in' => $included_post_ids,
'post_type' => 'page',
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => true
];
$my_query = new WP_Query( $args );
// ....
}
Information regarding query arguments can be found in the WP_Query
reference on the Codex.