My suggestion would be to pass different arguments to Wp_Query Class.
using ‘cat’ property, passing category Ids.
<?php
$custom_query = new WP_Query(
array(
'cat' => '1,2,3,4'
'post_type' => 'my_post_type',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
)
);
?>
OR
using ‘category_name’ property passing category slug’s as string parameters.
<?php
$custom_query = new WP_Query(
array(
'category_name' => 'category1+category2'
'post_type' => 'my_post_type',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
)
);
?>
More info about Wp_Query parameters:
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters
Hope it helps.
Good Luck.
Att
Related Posts:
- WP_Query not looking at child category
- Excluding posts from a category but only if they’re not in multiple categories
- Display one latest post from multiple categories
- Enter a variable in the ‘category_name’ parameter
- Multiple Loops on category.php with pagination on last loop
- Pagination on category.php and tag.php not working
- category__not_in and id values from variable
- Show multiple categories in query using redux framework variable
- Using in ‘category_name’ in ‘$query->set();’?
- multiple values in an array for category__and does not work with WP_Query
- the_category() doesn’t working in wp_query loop
- Get categories within specific term
- WordPress Numeric Pagination with Query String [duplicate]
- Printing direct descendants of a category with WP_Query
- Custom Category Page Not Working [duplicate]
- How do i add custom post types to this query?
- Order get_terms() By Custom Field
- Should category.php and The Loop be used if the query needs to be customizable?
- Exclude the category from the WordPress loop
- How can I get category ID by category name?
- get_field not displaying my custom field value
- Randomise results from a category page?
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- Custom query with category exclusion and post-meta “whitelist”
- Use get_term_children to get the sub category of a parent category for the current post
- How do I get the total number of categories in a list of search results?
- Update wordpress post terms programatically
- List all custom post type posts from a given category?
- Get a list of Terms for a specific category
- Display products for a category, sorted by post_excerpt
- a-z list, categories and sub categories in loop
- How do I get a list of all categories that a given user has written blog posts for?
- Set post categories to include parents when setting child category
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Additional featured post on first page
- Show all posts for a specific category/author
- Inserting Category programmatically
- create a page which displays a list of categories title+ short description?
- Query Posts Exclude Entire Category
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- How to order posts by title after they have already been sorted by category
- Get posts under a category with SQL
- Inside a loop, how to change CSS class based on category name?
- Categories list loop – add separator every 3 categories [closed]
- Display custom taxonomy attached to the post on post single page
- wp_dropdown_categories not showing option as selected
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Display posts from a category
- Trying to get variables in hacked category dropdown
- Display sibling categories on category page
- Count tags for a specific category
- Do not show sub categories in the loop on archive-product.php
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- Do not duplicate posts with multiple categories in multiple loops
- set terms to category and subcategory
- Two Sections on Woocommerce Catergory Page [closed]
- Getting the Most Recent Posts from Multiple Categories
- Display category title and three latest post inside the category
- Query posts by views on category page
- Are term_taxonomy_id and term_id the same? [duplicate]
- Custom Page Template Category loop not functioning correctly
- How to store category and tags separatly on wordpress?
- Limit Loop to One Category
- Filter Category Loop Dynamically
- How can I use AJAX with check-box categories?
- wp_delete_term or wp_delete_category?
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- Update custom category fields front-end
- Category name for all posts getting assigned to a single random post
- Category post count is not correct
- Include last post date in get_categories loop
- How to get specific (grand parent) category of current post?
- Custom Loop with certain number of one category
- how tho change number of posts in loop from specific categories
- Template category.php with page (no posts)
- Can’t display posts by filtering categories using isotope.js
- How to remove parent category from child category url using wordpress rewrite rule?
- error in specific category loop
- loop in single.php of the same category
- Hide a category/posts from the homepage in wp
- How to modify custom category field from front end?
- outputting taxonomy hierarchy
- Bulk Change WordPress category Slug
- Trying to display all posts in a category
- Getting a sub category based on a category name
- Display Taxonomies in loop with template args
- Unable to get all tags from specific categories
- How to get multiple loop in category.php, my scripts becomes madness
- WP_query exclude a category unless it has more than one catagory
- Custom loop by url
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Trying to WP_Query a category
- get_category_children/ the new get_term_children not work
- Taxonomy term RestApi data 10 rows limitions
- hide_empty property not working when using get_terms
- Get categories by title descendant