I would like to display the category thumbnail on my category page with a short code. Forgive me, I have very poor skills in PHP...
About the system : Wordpress 6.4.3 woocommerce 8.6.1 Theme : Divi 4.24.2
I found this topic, which helped me a lot : How to display Woocommerce category description with DIVI theme
I would like a similar code, but for displaying the active category thumbnail.
I tried to add this to functions.php, but not a success :
add_shortcode('cat_img', 'cat_img_shortcode');
function cat_img_shortcode() {
global $wp_query;
$cat = $wp_query->get_queried_object();
if( $cat == null ) return;
$output = nl2br($cat->thumbnail);
return $output;
}
if someone could help me this would be wonderful :)
You can use the following shortcode to display the product category image on product category archive pages, if available:
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.
Usage:
[term_image]