F
F
freeman02042018-09-26 12:30:31
WordPress
freeman0204, 2018-09-26 12:30:31

How to display headings with a picture (field acf) not on archive.php?

There is a template, in it you need to display headings with pictures. And when already by clicking on a category, it goes to archive.php and the posts of this category are displayed there. Everything works fine, but I can't display the category image in any way.
I did it through the acf field.
This code works on archive.php as mentioned here. https://www.advancedcustomfields.com/resources/add...
How can I make this simple template code work?

$term_image = get_queried_object();
$image = get_field('img_cat', $term_image);
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />

I render the rubrics like this:
$terms = get_terms('category');
foreach ($terms as $term) : ?>
    <?php $term_link = get_term_link($term);
    ?>
    <ul>
        <li><a href="<?php echo esc_url($term_link) ?>"><?php echo $term->name ?></a></li>
    </ul>
<?php endforeach; ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question