Hello guys,
I’m trying to create a page to show all the categories, with the cat name and featured image (acf).
My PHP is very poor and I can’t do this myself, can someone help me with this, please?
This is what I’m doing:
I have a page to show posts from a custom post type. I’m using the same code to show the categories instead of the posts, and for that I’m changing some lines of the code. Here’s what I did so far:
$categories = get_categories();
$image = get_field(‘image’);
$size = ‘full’;
foreach($categories as $category) {
echo ‘
<li>
<a href=”‘ . get_category_link($category->term_id) . ‘”>image_here</a>
<span class=”crp_title” style=”bottom:4px;”>’, (
strlen($title= the_title(”, ”, false)) > 48 ?
substr($title, 0, 48) :
$category->name
), ‘</span>
</li>’;
}
Everything is working perfectly, the only thing that is missing is the category image.
For the image, I’m using the ACF plugin.
ACF image key: field_63c3d989ab2a7
I’ve rad this but I don’t know how to use the code in mine. This is probably very simple, but like I said, I’m too newbie 😀
Can someone help me, please?
Thank you in advance!
[ad_2]