Kadence Theme Pro lets you add an image to post categories, but the dynamic settings don’t offer an option to display this image, so you can’t use it for things like hero backgrounds on element templates you use on category archives. The code below rectifies this. Once you’ve added the snippet to your site, in your block, make sure you have dynamic content activated, then choose Archive Custom Field, Custom Input, and add kwp-tax-image-id to the custom meta key field.

Dynamically display category image
add_filter( 'kadence_dynamic_content_render', 'kwptax_img', 7, 99 );

function kwptax_img( $output, $item_id, $origin, $group, $field, $para, $custom ) {
	if ( ! empty( $para ) ) {
		if ( 'kb_custom_input' === $para && strpos( $custom, 'kwp-tax-image-id' ) !== false && ! empty( $custom ) ) {
			$image_id = get_term_meta( $item_id, 'kwp-tax-image-id', true );
						if ( $image_id ) {
							$output = wp_get_attachment_image_src( $image_id, 'full' );
							if ( ! empty( $output ) ) {
								$output[4] = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
								$output[5] = $image_id;
							}
						}
							
			} 
		}
	return $output;
}

Add the PHP to your child theme’s functions.php file, or a code snippets plugin.

Code snippets are offered ‘as is’ and no support is provided. If you have customisation requirements, feel free to contact me for a quote.

Pro Pass Membership

Want access to all current and future child themes, kits, and our B&B Blocks library for Kadence for one low annual price?

Brand & Build Pro Pass

Latest

In the shop

  • Kadence
    Lane Wordpress Theme for KadenceLane Wordpress Theme for Kadence

    for content creators

    £175.00

    View Details 🡢

  • Kadence
    Liora Child Theme for KadenceLiora Child Theme for Kadence

    for bloggers

    £175.00

    View Details 🡢