ACF Taxonomy Field Value in Single Posts

ACF Taxonomy Field Value in Single Posts

Consider this scenario:

CPT: Movie

Movie CPT Taxonomy: Movie Genre

Movie Genre Taxonomy's field: Genre Color

Each movie will have only genre set.

The requirement is to get and use the genre color field's value either on single movie posts or in the movie query loop for each movie post.

This Pro tutorial shows how to set up a custom function that takes the taxonomy name and taxonomy's field name as arguments and returns the field value that can be used in the post loop when using ACF in Bricks.

The function is generic and can be used with any taxonomy and custom field of any type attached to that taxonomy.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Checkbox Sub Field as Unordered List in Bricks

ACF Checkbox Sub Field as Unordered List in Bricks

Updated on 22 Sep 2023 This Pro tutorial shows how the checked options of a Checkbox-type of Sub Field inside a ACF Repeater field can…
Categories:
Pro
Filtering ACF Relationship Query by Post Meta in Bricks

Filtering ACF Relationship Query by Post Meta in Bricks

How to filter the posts of a post type related to another post type based on the value of a True / False type ACF…
Pro
ACF Term Meta on Single Posts in Bricks

ACF Term Meta on Single Posts in Bricks

Consider this scenario: CPT: Project Custom taxonomy: Project Type Each project will be assigned only one project type. Project Type taxonomy's custom field: Project Type…
Categories:
Pro
Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

This Pro tutorial shows how we can prefilter the results of a query output by a Bricks query loop to only those for which the…
Categories:
Tags:
Pro
CPT Submenu Items in ACF Pro Options Admin Menu

CPT Submenu Items in ACF Pro Options Admin Menu

This Pro tutorial provides the steps to add links to admin pages under an Options page created with ACF Pro. All code mentioned in this…
Pro
Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

Related FAQs on Product pages Based on Product Category Taxonomy in Bricks

On product pages, we show all the FAQs associated with the current WooCommerce product's product categories.
Categories: