I have an action setup on pre_get_posts
which I would like to use post__in
on.
I used the following code as a test:
$query->set('post__not_in', array(74485,1528,71460));
This works, the total number of posts is reduced by those 3. However, what if I want to use post__in
to just return those 3 posts? I tried:
$query->set('post__in', array(74485,1528,71460));
But that didn't work. I thought maybe it was because post__not_in
is already being used (as the codex says post__in
and post__not_in
can't be used together. So I tried:
$query->set('post__not_in', '');
$query->set('post__in', array(74485,1528,71460));
But this still doesn't work.
Any help please? Thanks
pre_get_posts
on the same query. If so, why? What are you trying to dopost__not_in
(this also works with the large array of IDS I have) but I can't include only them. I suppose another way would be to get an array of all post ids and compare that to the array I have?$query->set('ignore_sticky_posts', 1);
but still no joy.