On your code, the function wp_get_post_terms() return an array of WP_Term objects, so you can’t access directly to an object property without specifying an index for the array like :
$terms[0]->slug
Otherwise, you should iterate through the whole array of terms and retrieve the slug into an another array, like :
$terms = wp_get_post_terms( $post_id, 'disciplines' );
$terms_slug = [];
foreach ($terms as $term) {
$terms_slug[] = $term->slug;
}
And finally, you can implode the all the gathered slugs into your class attribute :
class="filter-item <?= implode(' ', $terms_slug); ?>"
Related Posts:
- Get Posts by Custom Post Type ,Taxonomy, and Term
- Get The Post Type A Taxonomy Is Attached To
- Display current taxonomy term when inside custom post type
- Get term slug of current post
- How to limit the number of terms (terms acts like categories)
- How do I list custom taxonomy terms without the links?
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Custom Taxonomies Terms as Post Title for Custom Post Types upon Publishing
- wp_get_object_terms(): count relative to passed IDs?
- Not Able to Insert Taxonomy Term Using wp_insert_post()
- array_pop() expects array, boolean given for $event_type_term ->slug
- post count is wrong when using same taxonomy for 2 different CPT
- Maintaining strict one-to-one association between terms and custom posts
- Displaying custom post type by first letter through custom taxonomy
- If on term-page -> get the current term?
- Separate Custom Post Type Taxonomy by Comma
- Trouble adding custom featured image for custom taxonomy TERMS
- Get child terms of current term of the current post
- Creating a function that receives the taxonomy terms that have been changed in a custom post type
- Get all taxonomies for all post types
- Get the terms of a custom taxonomy for a specific author in author template
- How do I provide a “show all posts” link in a paginated term archive?
- How to get posts from multiple custom post types according to it’s custom taxonomy terms?
- How to output wordpress custom tags separated by comma?
- How to check the terms in single custom post type template
- Displaying a custom post types custom taxonomy value?
- Does WordPress limit the length of slug names for Post Meta or Terms?
- get_post_meta returns empty array for terms
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Update post terms with custom taxonomy
- Custom Post Type Archive Page Filtering
- Filtering WP_Query Dynamically on the Front-End
- Get template part using a custom taxonomy term
- Get posts by querying taxonomy and certain terms of the taxonomy?
- How to restrict users and admin from creating new taxonomy terms?
- using $wpdb to get custom post type with term
- Allow user to set custom order to a list of custom taxonomies?
- Displaying custom taxonomy in the admin list of a custom post type
- Which post does a taxonomy term belongs to?
- How do I display the taxonomy term alongside the post type post title?
- Post count by month of taxonmy term
- How do I display the taxonomy for a custom post type in an array
- Display Custom Taxonomy Alphabetically
- How do I require the specification of term in a custom post type and custom taxonomy?
- Custom Post, set object Taxonomy terms in plugin
- Custom while loop for hierarchical display of a taxonomy
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Display taxonomy terms, child terms and posts in a template
- Use custom walker to add taxonomy terms to main nav menu
- Add term to custom post type on draft
- Displaying custom-taxonomy-terms sorted by parent/child-hierarchy?
- Query posts with double taxonomy
- Adding predefined terms to a taxonomy
- Custom query – get_the_terms not work
- How to Display Posts From Category Within a Custom Taxonomy?
- The Difference Between Categories and Tags and Taxonomies and Terms
- custom hierarchical taxonomy and custom post type list contains surplus posts
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- how to count the current posts terms
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Custom Taxonomy Terms in Menu lead to which page?
- How can I get 3 different taxonomy type terms in a div class element?
- Get terms for a specfic post from multiple taxonomies in custom post type
- Add custom post type taxonomy tag to article class
- Custom Taxonomy dont save in a frontend form for post a custom post
- Add filter to Admin list for all custom post types by their custom taxonomies
- Add the custom post term to the custom post title
- Custom taxonomy not saving correctly
- Taxonomy terms with the same name are updated between separate custom post types
- Add a class to a div if custom post type has specific terms?
- display post count in archive page that have relation with another taxonomy term
- Return multiples taxonomies with wp_get_object_terms
- Custom taxonomy terms hierarchical navigation
- How to list posts by terms
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Get all posts for custom taxonomy term
- posts_per_page is not working by term
- Add active class to foundation 6 tabs while looping categories
- Saving Child Terms on front end not setting parent
- order taxonomy alphabetical
- Filter Term By Parent Term – Custom Post Type
- Filter By Term Not Working – Custom Post Type
- Display all Custom taxonomy terms and their relevant custom posts
- WordPress get all post with like in terms [duplicate]
- Get posts of an specific term of a custom taxonomy
- Best way to group posts based on custom post type terms
- Get list of CPT posts in *current* post’s taxonomy term
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- How to List CPTs Under One Tax Term
- How to retrieve the permalink for a specific (custom) term?
- Exclude Custom Post Type from shared Custom Taxonomy
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Get a list of categories ids
- taxonomy terms array not working
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- get_the_term_list() wanting to loop through the returned values
- List custom taxonomy terms
- Is it possible to get_terms by taxonomy AND post_type?
- Is there a way to edit non-custom term attributes?
- Can’t retrieve custom post type taxonomy term to custom post type editor