You can get posts from your custom post type by specific category or multiple categories by using tax_query
parameters with your WordPress Query.
Note: Whenever we work with a custom post type’s category, this category itself is called a taxonomy and the items inside that category, are called terms.
Before moving further, let’s understand the situation, that I am going to address further in this article. As you can see in the image below.
I have a custom post type called Events, and a custom taxonomy called Location, and I want to get all the posts from events by a specific location and multiple locations.
Get Custom Post Type By Single Category
To get all the events posts from the location India, I will pass india as value for terms within my tax_query. As you can see on line 7 in the snippet below.
Get Custom Post Type By Multiple Categories
To get all the events posts from different locations, like newyork, india, london, I will pass these values inside an array. As you can see on line 7 in the snippet below.