If you have the category ID you can use the category__in
parameter eg:
<?php $custom_posts->query(array('category__in' =>array(1,2,3))); ?>
Related Posts:
- How to return results of a get_posts() in explicitly defined order
- Modify main WordPress loop with a parse_query filter
- How should I intercept the main query and inject custom join / order by / group by criteria
- Dynamically excluding current page id
- How to order results by date and meta key?
- Static Front-Page Excerpts
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- query_posts() ALWAYS displays something?
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- Custom loops, sticky posts, and pagination nightmare
- Filter Loop by Custom Field Value
- Modify loop but keep the original query, what am I doing wrong?
- When to use WordPress loop or Foreach loop?
- Post per page not working if no category specified
- Calling Posts from Specified Cat
- Most Effective Method? Exclude Category and Number of Posts Per Page
- How do I query based on the modified date?
- Script that gets the first tag of post and query all other posts with the same tag
- Modify main loop query for paged and meta key
- Create a Loop with Posts Ordered by Most Recent Comments
- query_posts and sub pages?
- The_content display a different content from a previous loop
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Including post data in a sidebar occurring outside of and before the Loop
- Multiple loops with / without sticky posts and different post limits
- How to Get All Posts with any post status?
- posts_per_page no limit
- How do I exclude a custom taxonomy from the post loop
- How can i get count from query post
- Some doubts about how the main query and the custom query works in this custom theme?
- query_post by title?
- Why query_posts() isn’t marked as deprecated?
- Alternative to query_posts for main loop? [duplicate]
- How to get posts published between a date and today?
- how to query posts by category and tag?
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Order by meta value or date?
- How do I query by post format in WordPress 3.1
- Display posts of the last 7 days
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Filtering posts by post meta data
- WP_Query vs get_posts
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- Query posts by custom taxonomy ID
- Display/query post formats
- How to query post by user role?
- Display all posts from specific categories on a page
- Help to condense/optimize some working code
- Order posts by ID in the given order
- How to set posts per page using WP_Query()
- query_posts exclude a meta key
- How do I create a random post that will last for a day
- Ensuring sticky posts are retrieved first (without using two queries)?
- Determine if more posts are available than was asked for in `query_posts()`?
- Get the number of posts from the current page results
- How to exclude latest x posts from a paginated query?
- query_posts() in function makes global $wp_query out of sync?
- WordPress Custom Query to show posts from last x years
- Limiting query_posts to 1, regardless of sticky post?
- How to make “sticky” pages (and query by them)
- Build a content and excerpt grid loop with paging and options for # of posts
- Query posts: how to exclude results if post is in multiple categories
- Query Custom Meta Value with Increment
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- Display content from a specific category
- Problem with ‘post__not_in’
- Is `query_posts` really slower than secondary query?
- How to order posts by descending comment count on taxonomy page?
- Are there any scenarios where the query_posts may be used?
- Sort posts alphabetically by custom field value, insert divider between different letters
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Sort X categories by last update and show image
- Custom Post Type “Event”: chronological list of recurring events
- using post__in allow duplicate post id
- Pagination on archive.php page
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Retrieving 3 latest post from each of 5 different custom post types
- WordPress Custom Query
- Best way to load page content in Fancybox popup?
- advice on creating a ‘related posts’ query like the one used on stackexchange
- order post my meta value m/d/y format with year as included value
- Order posts by custom field and if custom field is empty return remaining posts
- Order by meta value, pro first, then free
- Having trouble generating pagination links on custom query
- How to create an attachments archive with working pagination?
- _wp_page_template to dynamically use template
- Multiple posts with one loop iteration
- Using dynamic conditions in ‘posts_where’ filter
- Help altering a query to exclude all but standard post format
- List users with the most total posts view
- Schedule Sticky Posts
- Use union/intersection query_posts variables in uri request parameter form?
- query_posts doesn’t order by title
- How to limit search to first letter of title?
- query_posts and pagination, still stuck after much research
- Query posts by taxonomy term name
- Sorting problem with ‘query_posts’ funcion in wordpress. Sort by custom field not working
- Total Count of Posts NOT in Selected Categories?
- Custom query with query_posts doesn’t show post without certain meta_key