情報を追記している場合はありますが、古い情報を訂正はしていませんので、公開年月日を参照してください。プラグイン・タグ、いずれもワードプレス・PHPのバージョン等によって動作しない場合もあります。
PHPのWarning が表示される設定のサーバーでプレビュー時に「undefined variable $post ~」と表示されるということで。
function acf_set_featured_image( $value, $post_id, $field ){
$type = get_post_type($post->ID);
if($value != '' && 'xxxx' == $type){
add_post_meta($post_id, '_thumbnail_id', $value);
}
return $value;
}
add_filter('acf/update_value/name=thumb', 'acf_set_featured_image', 10, 3);
なら
function acf_set_featured_image( $value, $post_id, $field ){
global $post;
$type = get_post_type($post->ID);
if($value != '' && 'xxxx' == $type){
add_post_meta($post_id, '_thumbnail_id', $value);
}
return $value;
}
add_filter('acf/update_value/name=thumb', 'acf_set_featured_image', 10, 3);
のように global $post; を入れるとWarning が出ません。