Try:
$tt = get_terms('my_custom_taxonomy', array(
// You can stick in orderby, order, exclude, child_of, etc. params here.
));
foreach ($tt as $term) :
// Output term name
print $term->name. ": ";
$q = new WP_Query(array(
'post_type' => 'custom_post_type_i_use',
'post_status' => 'publish',
'posts_per_page' => -1, // = all of 'em
'tax_query' => array(
'taxonomy' => $term->taxonomy,
'terms' => array( $term->term_id ),
'field' => 'term_id',
),
));
$first = true;
foreach ($q->posts as $item) :
// ... now do something with $item, for example: ...
if ($first) : $first = false; else : print ", "; endif;
print '<a href="'.get_permalink($item->ID).'">'
.$item->post_title.'</a>';
endforeach;
endforeach;
Does that do more or less what you needed?
Related Posts:
- Display all posts in a custom post type, grouped by a custom taxonomy
- Order custom posts by taxonomy?
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Taxonomy posts on Archive page
- Randomly placed sticky custom posts complemented by blog posts
- How to display the rest of categories on Portfolio filterable
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Query for posts in 2 taxonomies
- ‘category__and’ for custom taxonomy?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Custom Post Type Loop within Shortcode
- Filter by custom taxonomy slug on a custom post type
- Normal pages as children of my Custom Post Type
- Only show posts from a certain category?
- Display CPT posts based on specific taxonomy
- Am unable to reset a query properly
- get_attached_media() on author page not working
- Get next and previous 3 posts in a term in single post page
- Loop custom taxonomy to get lists of cutom post types?
- Custom loop with multiple taxonomy queries
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Display all taxonomy terms, add class if term applies to current post
- Return the latest post from a custom Taxonomy and Post Type
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Group CPT posts by custom taxonomy
- What’s the WP way to load remaining custom posts?
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Listing all term items alphabetically / sorting loop
- Display related custom taxonomy posts in sidebar
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- get_the_title() is returning results from previous loop
- Main query not querying any posts in custom taxonomy template
- Control content before and after custom post type loop
- looping though custom post types and only return results in a given taxonomy
- Dynamically insert code to custom post type loop
- Pull in taxonomy field of custom post type in new query
- Custom Post Type not showing in main loop
- My custom taxonomy is only displaying 1 of 3 terms
- get_terms() parent, child and grandchild
- List all Custom Post Type posts excluding certain Taxnomy term
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Looping through custom taxonomy and display custom post types (Custom Post Type UI)
- Create a custom taxonomy template that loops through child categories in term order?
- Loop and add Specific Categories and Products Images
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- What is the most efficient way to execute recursive complex queries?
- How can I loop at a Specific Taxonomy from a custom post type?
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- Custom archive page for custom taxonomy and pagination issue
- How to display list of custom post taxonomy terms and their posts (if any)?
- Custom post type paging return home page
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Some posts not displaying by taxonomy term
- Combine multiple separate lists into one
- posts_per_page is not working by term
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- List all posts associated under custom taxonomy
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- Display title of all custom posts from same taxonomy term on a custom post template
- Loop to display parent categories in custom taxonomy
- Custom taxonomy template for custom fields loop [closed]
- Add active class to foundation 6 tabs while looping categories
- How to show terms used only for particular custom post type. Filter creation perpose
- Show posts for current taxonomy
- Custom post types not displaying per category
- WordPress query posts by custom post type not workng
- Custom post type with custom taxonomy permalinks
- Custom taxonomy page template
- Loop with Custom Post Type and Taxonomies
- Loop multiple taxonomy in custom post
- Post data in separate divs with incrementing class using WP_Query
- WordPress Custom Post Type and sort by Tags
- Display posts from category in page
- Order by custom field attribute
- Display Custom Taxonomy of custom post type
- Sorting custom post types by taxonomy (So close)
- Looping taxonomy in taxonomy?
- Listing custom post type items from a couple of custom taxonomies
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Catergory args causing loop not to show
- display custom post type from register taxonomy
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Complex Custom Loop with Includes
- Create a WordPress loop that shows posts from a custom post type + filters the posts by taxonomies while hiding empty taxonomies
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template