I think ACF is an awesome plugin and it’s made very friendly for people like myself who isn’t much of a programmer. So, thank you!
However, I’ve stumbled on a wall. After I managed to add the image option to my custom taxonomies (categories), I can’t seem to display the category images in my Sidebar. The only thing which output is the category title and description, no image.
Below is the code I’ve used.
<?php
$args=array(
'hide_empty' => '0',
'taxonomy' => 'product_categories'
);
$categories = get_categories($args);
foreach($categories as $category) {
$image_url=get_field('product_category_image', 'category_'.$category->term_id);
echo '<img src="'. $image_url .'"/>';
echo '<b>'. $category->name .'</b>';
echo '<p>'. $category->description .'</p>';
}
?>
Could you please guide me as to what I’m not doing right? Thanks.
Hi @dannyfoo
The $post_id parameter mush be a mixture of the taxonomy and the term_id.
Please change your code to:
'product_categories_'.$category->term_id
You can also just pass in the $term object like so:
$image_url=get_field('product_category_image', $category);
Thanks
E
Thanks so much for the guidance @elliot! Images are now showing.
Now to go search in the forum on how others have managed to set a custom size and later read up a little more on the $post_id paraments.
Thanks again.