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
- WP Query filtering by custom category not showing all relevant posts
- How to determ a custom post type url?
- Displaying custom taxonomy in the admin list of a custom post type
- Separate custom categories from default category
- Tax query not producing any results
- forming WP_Query for posts of all post types but from specific categories
- wp_list_categories() – current-cat class also inside posts?
- Showing posts from different categories and from custom post type
- filter custom post type by meta key in dashboard
- Custom post type getting wrong categories and tags
- Which post does a taxonomy term belongs to?
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- Meta query for custom post type ignored in main query
- PHP variable not regenerating when publishing multiple posts at the same time
- Display post as term id
- Multiple level category drop-down from the WordPress dashboard
- How to filter wp_list_categories output with some custom post type meta query?
- 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
- Display a CPT based on a metabox selection
- How do I display the taxonomy term alongside the post type post title?
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Problem with displaying posts in the CPT category
- Issue on Creating Custom Tax Term Dynamically From Another CPT Meta-box On Publish
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- Post count by month of taxonmy term
- How to do WP_Query with two meta fields with orderby clause
- Stuck in Order by more then one
- Custom Post Types with a common category for a blog listing
- Can’t remove front from permalinks for custom taxonomy category page
- How to get categories linked in posts for a specific post type
- Meta Query Not Returning Output Despite Having Matching Values
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Custom post type, organized by categories
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- WP Meta query for a custom post type based on two values
- Remove CPT name from permalink but add %category% instead
- Set a checkmark in a category based on a URL-parameter
- WP Query with categories only shows one post and ignores the category
- How do I display the taxonomy for a custom post type in an array
- Custom Widget WP_Query problem
- Adding custom post type to count in category
- How do I display the grand child items of a taxonomy term?
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Custom Post Type and Category Base Rewrite Issue
- Get the category from custom post type
- Post injections into Site Origins Page builder [closed]
- Custom Post Type + Categories
- Display Custom Taxonomy Alphabetically
- How to create a gallery page with categories?
- Custom Post Slug same as Parents Category Slug
- WordPress posts page for customer filtering and sorting along with category filter
- How do I require the specification of term in a custom post type and custom taxonomy?
- Custom Post, set object Taxonomy terms in plugin
- I am having Trouble to get list of Categories of Custom post Type
- Hierarchy and access control for Custom Post Types (CPT)
- Multiple (two) category postings on the same page.
- How to include term custom meta into the custom taxonomy term permalink structure
- Loop filtering Custom Post Types and/or Categories
- Setup template_redirect using has_term when NO term assigned
- search suggest – filter post type
- School & class blogs: Categorize with categories or custom posts?