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 by category titles
- How to remove specific categories from posts?
- Get posts from specific taxonomy term
- Get posts under a category with SQL
- ajax for filtering posts by category in wordpress loops
- Inside a loop, how to change CSS class based on category name?
- Exclude current post from loop
- Getting category URL with hyphens, not spaces
- How to insert category list into post creation page, and retrieve chosen categories?
- Categories list loop – add separator every 3 categories [closed]
- Set colors depending on category
- get_terms function not returning anything
- Display custom taxonomy attached to the post on post single page
- Limit get_categories to show each category once
- wp_dropdown_categories not showing option as selected
- Display single category name in woocommerce loop
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Show Posts from Single Category Not Working
- Get a count of how many times a term or a category is used in posts
- Is there a reason I cannot get the current category in a loop?
- Category archive is displaying all posts rather than the specific category
- Display posts from a category
- Custom loop of a single category, cannot order by date. What am I missing?
- new WP_Query all post in a category inside the loop
- Trying to get variables in hacked category dropdown
- Problem with different query loops (and “main loop”) on category template page!
- How to do paging in the loop?
- How to add orderby parameter for sorting on category.php
- Get Categories Where Taxonomy Equals ‘n’
- Use premade array as categories in wp_query?
- Display sibling categories on category page
- How to loop custom post_type from (a) specific category(ies)?
- Count tags for a specific category
- Do not show sub categories in the loop on archive-product.php
- How to Link to Most Recent Custom Post of Same Term
- wp_query is showing posts from other categories
- How to display the parent category if only the child category has been chosen
- Category tags with comma’s
- Display posts of certain categories to specific user roles
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- Check if a post has term inside loop
- Do not duplicate posts with multiple categories in multiple loops
- Simple way to style posts of a single category differently in the loop and in single
- set terms to category and subcategory
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- WP_Query with one category in args shows other categories
- Getting the Most Recent Posts from Multiple Categories
- Getting Category Children
- Display subcategories in dropdown
- Display category title and three latest post inside the category
- WP_Query – using category__and when one of the categories is 0
- Adding a block with query in homepage
- Query posts by views on category page
- Showing HTML if Post is In Certain Taxonomy Term
- Have posts that belong to multiple categories, exclude some categories from homepage
- Category nicename inside loop in wordpress
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- Get the ID of the current post’s child category
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- Are term_taxonomy_id and term_id the same? [duplicate]
- WP_Query of Category Not Showing First Post
- Return category posts with WP_Query
- Custom Page Template Category loop not functioning correctly
- How to store category and tags separatly on wordpress?
- Retrieve post tags from from main wp_query
- Limit Loop to One Category
- Display post thumbnail for specific category outside the loop
- List post only under the category, exclude child category content
- Posts of specific category on page and excluded from index.htm
- new WP_Query issues
- Filter Category Loop Dynamically
- Post to inherit custom category background image from parent
- How can I use AJAX with check-box categories?
- Editing Loop So It Targets Specific Tags?
- wp_delete_term or wp_delete_category?
- Select posts that match multiple category names, must match all categories listed
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- How to display the 5 latest post titles but allow only 1 in there of a specific category
- Avoid WP_Query’s duplicate posts with taxonomies