0
votes

I have created fields group for my blog categories using Advanced Custom Fields (https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/).

When i create basic text field, it is easy to echo it on category.php using:

$terms = get_the_terms( get_the_ID(), 'category');

if( !empty($terms) ) {
    $term = array_pop($terms);
    $custom_field = get_field('some_text_field', $term );
}

echo $custom_field;

But instead of basic text field i created a group (called call_to_action) with 4 fields inside it (image, title, subtitle, link). Now, if i try to create different variables, like:

$custom_field1 = get_field('image', $term );
$custom_field2 = get_field('title', $title );
$custom_field3 = get_field('subtitle', $title );
...

and echo them, nothing happens.

I am guessing this is because they are located in "call_to_action" group... and i really dont know how to make them show up... I am only starting with PHP and any ideas would be really greatly appreciated

1

1 Answers

0
votes

Try This way

$custom_field3 = get_field('subtitle');

OR

global $post;  
$custom_field3 = get_field('subtitle',$post->ID);

OR

$custom_field3 = get_field('subtitle',get_the_id());