Home Forums General Issues Featured Image Not Displaying


Featured Image Not Displaying

  • Hello,

    I have just set up my first custom post type. I have used ACF to add an image field called artwork_example_1

    I would like this field to be treated as the featured image of the post, so following a recent thread i have added the following code to functions.php

    // set artwork_example_1 as the featured image  
    function acf_set_featured_image( $value, $post_id, $field  ){
        if($value != ''){
    	    //Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	    update_post_meta($post_id, '_thumbnail_id', $value);
        return $value;
    // acf/update_value/name={$field_name} - filter for a specific field based on it's name
    add_filter('acf/update_value/name=artwork_example_1', 'acf_set_featured_image', 10, 3);

    Unfortunately the image isn’t showing up! You can see that on this page where have tried with 3 different grid layout plugins to see if I can get it to display.

    Perhaps there’s an easier way to do this…Please can someone help me fix this?

    Many thanks

  • Hi @daniish

    Sry for asking. But..
    Why you do not use the standard featured image from wordpress?
    I saw that you use custom post types for the “artists”.
    You can easily activate the “featured-image” functionality for your post-type “artist” in your “register_post_type” function in the functions.php.

    'supports' => array( 'title', 'editor', 'thumbnail' )

    Let me know if u need more help with that.

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

The topic ‘Featured Image Not Displaying’ is closed to new replies.