http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ prety much covers what you’re after I believe.
So in your example
while ( $projects->have_posts() ) {
$projects->the_post();
$category_classes = array();
$categories = get_the_terms( get_the_ID(), 'project_category' );
if ( $categories ) {
foreach ( $categories as $category ) {
$categories_included[] = $category->term_id;
$color = get_field('color', 'project_category_'.$category->term_id);
}
}
You can also pass a term to get_field and the_field, so you could also use the following depending on your version of ACF as I believe much older versions don’t support passing terms
$color = get_field('color', $category);
Related Posts:
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Get Custom Field Values by Another Custom Field in WordPress
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- ACF – Retrieve custom taxonomy from a relationship field
- Display Custom Field or Custom Taxonomy in front page /post/product
- Custom Sort Order for Custom Post Type Taxonomy
- How do I associate a custom post type with another through a taxonomy or storing an ID in a custom field?
- Custom Taxonomy terms aren’t getting referenced or saved in Quick Edit or Bulk Edit, only on Single product page?
- Bulk Update Custom Fields for Custom Post Types
- WP_Query order by custom field, then randomly order some of results
- Show custom post type relationships by taxonomy
- Query custom post type with ACF Date
- Meta Query Not Returning Output Despite Having Matching Values
- ACF From & To Date Validations
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Dynamic dropdown select values depending on other custom field value
- How to render a custom post type template with custom fields using shortcode
- Order Custom Post Type by Custom Field Value
- Query Custom Post Type Taxonomy term with multiple parameters
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- First custom field value (out of several) displayed twice after query
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- How to group posts and get a mixed posts and groups view?
- Multiple Frontend Filters Using Advanced Custom Fields
- Integrate Custom Post Type Events into Calendar
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Show fields based on taxonomy selection in editor
- Permalinks: custom structure for taxonomy – tags?
- WebP Fallback for Inline Background Image in Style Attribute
- Query based on custom fields start and end date
- Custom post type’s extra fields – how to handle?
- How to get a custom type post data when it has a connection with another custom type post?
- Creating custom post type with custom taxonomy and custom fields programatically
- List of users that clicked a ‘Join’ button at single post
- Targeting categories in custom fields
- Custom taxonomies to define versions of a product
- How to inherit field value from parent post into in child / sub post
- Custom Taxonomy Search result page
- Custome fields not displayed
- How to get_term_meta on single custom post?
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- Many to many to many custom post relationships
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- How to define the template for custom posts?
- posttype and custom fields on multisite
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How do I replace the post title with a custom field?
- Sum and count of custom field values
- How to fetch custom post types with its full data on wordpress?
- Reusable metabox backend and frontend
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Get custom term meta problem on single post type
- Custom post type name and assigning custom taxonomy
- Group by custom field value (start and end times)
- Custom post types, disable fields
- Building a Portfolio and need some direction
- Custom post types category
- Custom Taxonomy dont save in a frontend form for post a custom post
- Excerpt length: get first paragraph
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Should i use custom post type for a custom footer?
- Order custom posts by taxonomy, then by meta_key
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Writing a custom Glossary plugin
- How do I ensure that post_type and Taxonomy use the same slug?
- add_filter get array data before display in custom post_type
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Custom taxonomy terms as children of multiple custom post types
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Custom front-end form for adding post – Category problem
- Create if else for post types in WP_Query ‘post__in’ values
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Display Posts that fit a certain criteria on Category pages
- WP_Query not using custom taxonomy categories on custom post type
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- wp_insert_post deleting previous post custom meta
- If ACF Post Object post has custom taxonomy term…
- Some posts not displaying by taxonomy term
- PHP Warning with Custom Fields
- I want to create a metabox under custom taxonomy
- Taxonomy shows up twice on Custom Post Type
- How to display custom post type pagination buttons when processing AJAX request
- filter using custom fields
- Adding a Section for Visitors
- Display custom tax in “while” loop
- Autofill advanced custom field with user data
- Advanced search form with multiple custom fields
- Query posts by multiple custom fields
- Custom taxonomy template for custom fields loop [closed]
- Best way to have one product in both rental and sale parent category
- Create Inclusions and exclusions
- How do I display specific custom posts, and how do I edit a post’s singular page?
- Fixed custom fields depending on posttype/category
- What’s the most efficient way to get two queries based on an if statement?