I have two categories that will always stay the same. They are called "Events" and "Show on frontpage". The latter is a child category to Events.
What i want to do is, when fetching posts (using WP_Query), check if the post is in the Events category. If it is, and it is NOT in the "Show on frontpage" category, don't fetch the post at all.
Scenarios:
- post is in Events but NOT in Show on frontpage: Don't fetch post
- post is in Events AND in Show on frontpage: Fetch post
- post is NOT in Events: Fetch post
The goal is to achieve the functionality only using WP_Query. Maybe it's possible using some special category__in
or category__not_in
queries or something. The trick is to kind of have an if
statement inside the query, because there are three possible scenarios.
Ideas?
continue;
. The problem is, if i have set wordpress to display 10 posts per page, and it skips some posts, then i will end up with less than 10 posts whenever the don't fetch scenario is met. This is a bigger issue than it seems, because i'm loading more posts using ajax, on some pages it only fetches one post per "load", so if that post is skipped, the script will assume there are no more posts, and return nothing.