Hi. I can not solve one problem. I would be grateful for any help )
I get a list of rubrics through the get_categories function.
$categories = get_categories( array(
'type' => 'post',
'child_of' => '',
'parent' => '',
'orderby' => 'id',
'order' => 'DESC',
'hide_empty' => 0,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => 0,
'taxonomy' => 'category',
'pad_counts' => false,
'fields' => 'all'
));
Next, I show everything in the loop. Plus, I display the image added through the ACF field.
<?php if($categories){foreach( $categories as $cat ){ ?>
<?php
$img = get_field('icon_rubrica', 'category_'.$cat->term_id);
?>
<img src="<?php echo $img['url']; ?>" />
<?php }}?>
Everything is working. But the get_field code creates a lot of additional requests in the database due to the fact that it works in a loop. For each iteration of the loop, it creates an additional 3 queries to the database.
Is there any way to get all the required fields at once, don’t use a cycle? With one overall request?