I have an array of post types and I want to fetch all categories or terms which only belong to these post types. Like product post type have a category with the name "product_cat" I used get_terms()
but it returns all available terms. If I use get_categories()
It returns only terms of post type.
$post_types = array('post', 'product', 'page');
3
Answers
You can to get it next – example of getting all custom taxonomy
brand_categories
of custom postbrand
Try with this code to get categories of post type product –
For retrieving the categories need a taxonomy.
You must use the taxonomy without taxonomy can not get term details.