Support

Account

Forum Replies Created

  • Hi Jonathan,

    We are going to use ACF to create a new featured image to replace the existing core featured image in posts. We have an existing multisite with Polylang. The code is working great on our development site. It replaces, updates, removes, etc etc .. works great.

    But.. it doesn’t show the current selected core featured image when you edit the post the first time. When you click edit on a post it doesn’t show a featured image for the new ACF featured image even though the post has one attached to it.

    How can we put the existing core image into the ACF image when you click edit the first time?

    // REPLACE FEATURED IMAGE WITH ACF
    function acf_set_featured_image( $value, $post_id, $field ){
    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=pfimage’, ‘acf_set_featured_image’, 10, 3);

    // hide existing featured image
    add_action(‘admin_head’, ‘my_admincss’);
    function my_admincss() {
    echo ‘<style>
    #postimagediv.postbox {
    display: none !important;
    }
    </style>’;
    }
    // END REPLACE FEATURED IMAGE WITH ACF

    Thanks,
    David

Viewing 1 post (of 1 total)