This would work. As posted by @bucketpress.
$someposts = get_posts(
array(
'post_type' => 'work',
'posts_per_page' => -1,
'fields' => 'ids', // return an array of ids
)
);
$somepoststerms = get_terms(
array(
'taxonomy' => 'category',
'object_ids' => $someposts,
'hide_empty' => true,
)
);
Related Posts:
- Cannot get to work tax_query array for terms
- Glossary with Custom Post Type
- Combine tax_query and meta_query in WP_Query
- List all custom post type posts from a given category?
- get_terms won’t display product_cat or any other custom taxonomies when specified
- How to get category image custom post type taxonomy in wordpress?
- Query for custom post type objects in a taxonomy and with a meta value
- Category page only displaying the posts from a custom type
- Custom Post Type Archive Page Filtering
- Allow user to set custom order to a list of custom taxonomies?
- Custom post taxonomies as tax_query terms?
- Why is this query not working? (Standard posts + custom post type)
- Using meta_query and tax_query at the same time
- How to get custom posts sub category link
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Get parent category id from child category page for custom taxonomy
- Category archive in with conjunction with custom post type is empty
- WP_query – Filter by tax_query and meta_query using multiple select
- How to Display Posts From Category Within a Custom Taxonomy?
- The Difference Between Categories and Tags and Taxonomies and Terms
- Get terms for a specfic post from multiple taxonomies in custom post type
- Retrieve Custom Taxonomies with Description and Slug
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- How to display custom taxonomy term specific post?
- get taxonomies from terms
- Not able to get my custom search result using meta_query and tax_query together?
- Get a list of categories ids
- Using get_terms() as shortcode attribute
- Using tax_query to get single post per category
- WP Query Conditionally query meta and taxonomy
- Exclude a category from WP_Query
- Custom Post Types on Category Pages
- WP_Query orderby custom field then post_date in one query
- query multiple taxonomies
- wp_set_object_terms() is not replacing term, but creating a new one
- How to list all categories and tags in a page?
- show tags of custom post type ONLY
- Pagination not working with custom category template
- filter search result with custom post type meta key
- Anyway to assign custom post types to a specific category?
- List with categories, subcategories and posts of custom posttype
- Sort the main query in subcategories/terms?
- Can’t sort order of wp_query with 2 meta keys
- Automatic category for a Custom Post Type
- How to get the first term for the current taxonomy?
- Display Custom Category (taxonomy) Name in Custom Post Type
- Ignore sticky posts if post is not in meta query
- Multiple custom post type loops in category.php
- Have a Custom Post Type index page display taxonomy items instead of posts
- How to get the post type from a category id?
- Set menu active state for custom posttype and category, given custom taxonomy term
- Query custom post type by category slug
- Sorting Custom Post Type by Meta Value but wont display when set to 0
- Get posts between custom dates
- How to display custom taxonomies with links in filter menu?
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- How to Filter custom post type by taxonomy?
- Add custom post type settings to wordress default posts
- Hide parent categories when clicked, and show it’s childs
- Custom post type, organized by categories
- WP Meta query for a custom post type based on two values
- Multiple (two) category postings on the same page.
- School & class blogs: Categorize with categories or custom posts?
- Adding predefined terms to a taxonomy
- Can I restrict category availability?
- Custom query – get_the_terms not work
- Targeting categories in custom fields
- Assigning a category to a custom post type in WordPress
- Stores category posts in an array
- custom query with custom post type and category slug
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Use post in multiple places on a page with multiple posts
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Archive Template being used instead of Category Template for Custom Post Type
- Add filter to Admin list for all custom post types by their custom taxonomies
- Custom post type specific category box
- Custom Taxonomy Taxonomies of Same Name point to first created URL
- Taxonomy terms with the same name are updated between separate custom post types
- category.php not showing custom post types
- How to automatically create a terms based on each post of a post type
- custom post type and a “sticky” position taxonomy
- Post category behave like a Post in back office menu
- Save data is post using php front end
- Custom taxonomy terms hierarchical navigation
- Modify category permalink to use post type slug
- How to output custom post type title on custom page with category next to it?
- Create custom post type categories
- ACF meta_key and meta_value break loop
- How can I get the last 5 element of this tax query?
- Meta_query by date for Events archive
- order taxonomy alphabetical
- WordPress get all post with like in terms [duplicate]
- Query breaking with ‘posts_per_page’ => -1
- can’t see categories in appearance-menu-categories
- Exclude categories For Custom post types
- How to retrieve the permalink for a specific (custom) term?
- Display all post types together
- Trying to create hierarchy between 3-4 custom post types
- Querying meta values within an array
- Custom Post Types Permalink