|
How can I query all the posts from either the custom post type (‘videos’) or with a post category (‘video’) in a loop? I’ve managed to create a query that combines the posts from a custom post type and the normal posts using the code below, but am struggling with achieving the same with a custom post type and a post category.
Any help would be appreciated! This is what my slides look like:
} First off, I get a If I’m just doing everything wrong here please let me know and I’ll go ahead and close this question. Thanks again for you time. |
||||||||||
|
Answers
|
Must have both The following arguments array searches for the post-type-slug
Either this or that If you are trying to show posts with EITHER the post-type OR the category slug, use two queries, because they are NOT combinable by any means of the arguments array.
However, I am noticing that you are using With
|
||||||||||
|
|
To do an OR rather than an AND, you would need custom logic, and it would be a hassle, but an unnecessary one! Instead of trying to get the posts AND the category, you should do 2 individual queries to grab what you want, so grab all the video posts, put them in an array, then grab all the posts in the video category, add those to the same array, then print out what you’ve got. Kind of like putting oranges in your shopping cart, then putting bannanas in, rather than looking endlessly for a box that has both oranges and bannanas together
You will need to modify this line which appears twice:
So that it contains the slide html for the post, so I imagine it will likely be an li element, some calls to grab the featured image, etc but that’s beyond the scope of this question ( which is regarding queries, not how to setup JCarousel slides and featured images ). |
||||||||||
|