Adding ACF field to category template

Hi there
I’ve created an ACF field as a wysiwyg inside my categories form in my dashboard.

That works smoothly.

Now I want to display the content I wrote after the posts listed inside my categories pages.

How to show this content ?
Which file do I have to edit to do this ?
I’m using renew.
If I’m correct, I do need to add this code inside my temple, am I ?

<?php the_field('name_of_field'); ?>

Thanks

Hi There,

You have to install and activate the child theme first: https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57.

After that add this custom code under functions.php file locates in your child theme:

add_action('x_after_view_global__index', 'print_acf_shortcode');
function print_acf_shortcode(){
  if(is_category()){
    $term = get_queried_object();
    the_field('name_of_field', $term);
  }
}

For more information about getting the value of category object, please take a look at this: https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/.

Hope it helps :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.