D
D
Daniel Tsioma2018-05-19 15:03:48
WordPress
Daniel Tsioma, 2018-05-19 15:03:48

How to display a category image on a WordPress site (Advanced Custom Fields)?

Good afternoon!
There is such a design:
5b001210a844f727876277.png
As you can see, you need to display the categories in this way:

  • name of category
  • Category image (made using a custom ACF field)

The normal wp_list_categories() function doesn't work because it outputs a normal list.
Thanks for the help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alvvi, 2018-05-19
@alvvi

Adding fields to a taxonomy term
TL;DR: Add a group of fields to a taxonomy, output the same as a post field, only passing the taxonomy object, how to get it in the dock

C
CODALSD, 2018-05-19
@CODALSD

<?php
          $id_page = get_the_ID();
      $args = array(
       'post_type' => 'Выбор страницы или категории где остальные категории перечислены'
                          //Тут допаргументы вывода
      );
      $query = new WP_Query( $args );
          while ($query->have_posts()) : $query->the_post(); ?>	
сам контент
    
<?php 
  endwhile;
  wp_reset_query();
?>

This is the categories output loop
<?php $image = wp_get_attachment_image_src(get_post_field('Название поля'), 'full'); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php echo get_the_title(get_post_field('Название поля')) ?>" />

And this is how it displays images, the call must be inside the loop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question