Page with all categories with featured image

[ad_1]

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]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer