S
S
Sergei Gurdjiyan2016-04-11 20:51:01
WordPress
Sergei Gurdjiyan, 2016-04-11 20:51:01

How to output an ACF field in a category loop?

<?php
$args = array("child_of" => $catalog);
$categories = get_categories( $args );
if( $categories ){
  foreach( $categories as $cat ){ ?>
    <div class="text_category"><?php the_field("intro_text"); ?></div>
<?php }} ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-01-22
@Stuliev

It was also necessary to display categories with images that are set using AFC.
To display the field of a specific taxonomy or term, you need to get the id of the current category and add the value like this:

<?php 
$term_id = $cat->term_id;
the_field('intro_text', 'term_' . $term_id ); 
?>

The answer was found at the link https://wp-kama.ru/plugin/acf/dobavlenie-polej-kt...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question