Support

Account

Home Forums ACF PRO Category Images not working

Helping

Category Images not working

  • Hi there,

    I’m trying to add a custom field to the category edit screen that will allow my client to add an image to the category.
    I’ve created a new image custom field called ‘kategorie_bild’ and set it to return the image ID. The field is set to display for all taxonomy terms. The term appears successfully and I can add an image however I cannot get it to appear on my archive.php template.

    Here is the code I am using:

    <?php
    
    $attachment_id = get_field('kategorie_bild');
    $size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
    $image = wp_get_attachment_image_src( $attachment_id, $size );
    
    ?>
    
    <img class="image-class" src="<?php echo $image[0]; ?>" />

    Can you please advise what I’m doing wrong?

    Thank you

  • When getting values for anything other than a post you must supply the correct $post_id value to ACF so it knows where to get the value from. For terms it is explained here https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/ and all of the different values that might be needed are explained in the get_field() documentation here https://www.advancedcustomfields.com/resources/get_field/

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Category Images not working’ is closed to new replies.