Get value in custom field with taxonomy [closed]

I can’t really explain it any better than the ACF documentation page I posted in the comments:

All the API functions can be used with a taxonomy term, however, a second parameter is required to target the term ID. This is similar to passing through a post_id to target a specific post object.

The $post_id needed is a string containing the taxonomy name + the term ID in this format: $TaxonomyName_$TermID

So if your custom field is my_cf, and your taxonomy name is basic (not term name) and the term ID within your taxonomy is 42, then you need:

$variable = get_field( 'my_cf', 'basic_42' );

Leave a Comment