If you use return
then your loop will not work properly. You can try the code this way:
<?php while($portfolio->have_posts()) : $portfolio->the_post(); ?>
<?php $term_class="";
$categories = get_the_terms($post->ID, 'project_type');
foreach($categories as $category){
$term_class .= ' ' . $category->name;
}
?>
<div class="portfolio-tile <?php echo trim($term_class) ;?>">
<?php the_post_thumbnail('medium' ); ?>
</div>
<?php endwhile; ?>
</div>
<?php wp_reset_query(); ?>
Related Posts:
- Filtering a custom post type by custom taxonomy in archive template
- get term archive url / link
- Get term slug of current post
- Create a shortcode to display custom post types with a specific taxonomy
- List the categories under custom taxonomy
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- The Operator “NOT IN” Does Not Work In tax_query
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Populate Taxonomy from Custom Posts
- Show related posts on single page by custom taxonomy on custom post
- Exclude from search all custom posts which are NOT in a taxonomy term
- Sorting for each custom taxonomy
- Post type archive page not working
- How to get the parent’s taxonomy?
- Dynamic variable for custom taxonomy in loop?
- Help with hierarchical custom taxonomies and permalinks…almost there
- wp_insert_post custom taxonomy
- How to get only one category of custom post type?
- Create separate template for shared custom taxonomy with shared terms
- Get URL for specific post type and current tag
- Append taxonomy terms as class names in markup?
- Want to turn WordPress into a paid subscription directory
- Connecting a taxonomy with a post type
- How to achieve representation of streets index with custom taxonomies
- Optimised Code for Pulling Taxonomy Posts
- Why is my custom loop not filtering correctly nor paginating?
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Custom post types with custom directories
- How to filter custom taxonomy categories on archive?
- How to output wordpress custom tags separated by comma?
- get_terms showing all categories instead of the ones assigned to a specific post
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Custom Taxonomy Permalinks Redirection
- Custom template won’t load for a custom post type (custom permalinks used)
- shortcode to show custom post types by category
- Single Template that can be applied only via URL
- Genesis filterable portfolio isotope [closed]
- Adding a custom post type taxonomy template in plugin
- Loading custom content type from ajax results?
- Custom post type and taxonomy – show related posts
- How to hook custom taxonomies to custom post types and make the permalinks work?
- Add custom image size for custom post type or taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- Allow duplicate slugs for custom post type with taxonomies
- Display a grid of taxonomy terms at root taxonomy page
- Display Custom Taxonomy Alphabetically
- How to make custom taxonomy into drop down select in a custom metabox
- posttype/taxonomy/term archive page 404 error
- How to add attributes to taxonomies that may be different from post to post?
- Custom post type, permalinks, taxonomies and blog posts
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Taxonomy in URL
- Display related custom taxonomy posts in sidebar
- Custom Post Archive is not working
- How to list tags from custom post type attachments?
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- How to setup a single post page for my custom post type?
- Implementing Pillar Posts; Long Posts yet with Some Page-Like Handling?
- Dynamically insert code to custom post type loop
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Custom taxonomy template list not working (404)
- Link From Single Post To Taxonomy Term Archive Page
- How to display custom taxonomy term meta on custom post type
- Print all the tags from a custom post type
- How to organize custom post type list by year?
- does wp_insert_term link the term to a certain post ID?
- Calling related posts to a custom post type, taxonomy & Tag id
- Custom post type category permalinks and archive pages
- Better in the long run to use post date or custom taxonomy to sort/separate posts by year?
- How to create subdomain for custom post type and associated custom taxonomies
- add_filter get array data before display in custom post_type
- Custom endpoint filtering post by custom taxonomies
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Define multiple prefixes for custom post type
- Remove custom taxonamy slug with pagination
- Taxonomies are not showing in the category dropdown
- get_the_terms child terms for current post/custom post only
- Order archive custom posts by taxonomy term [duplicate]
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Problem displaying posts for a category in a custom taxonomy
- Create Inclusions and exclusions
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Custom taxonomy- only output relevant terms
- Post types showing tables…Can I do that?
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Same permalink structure for all post types?
- Dropdown switching subcategories portfolio
- How to solve performance issue caused by custom post type overview with 20k+ custom taxonomy terms
- Prevent repetitive terms in get_the_term_list
- Displaying posts exclusively in their category (not parent)
- Show taxonomies from specific CPT
- Category / Custom Post Type permalink issue
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Advise on Custom Taxonomies and Structure
- Custom taxonomy meta fields
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- How to add categories to a custom post type using wp_insert_post($new_post);
- Modify permalink of CPT archive to support two taxonomies
- WP Query – Can’t get posts with specific taxonomy