php - Display ACF data as post title on 'publish' of Wordpress post? -


here code:

function my_post_title_updater( $post_id ) {  $my_post = array(); $my_post['id'] = $post_id;  $brand = get_field('brand'); $asset = get_field('asset'); $language = get_field('language');  $countryfield = get_field_object('country'); $countryvalue = get_field('country'); $country = $countryfield['choices'][ $countryvalue ];  if ( get_post_type() == 'project' ) {   $my_post['post_title'] = $brand . ' ' . $asset . ' ' . $country . ' ' . $language ; }  wp_update_post( $my_post );  }  add_action('acf/save_post', 'my_post_title_updater', 20); 

on publishing wordpress post function supposed create title based on few advanced custom fields. @ moment gets 'brand', 'asset' , 'language', not 'country'. however, upon clicking 'update' of post display country in title.

any appreciated.

try:

$country = $countryfield['choices'] . $countryvalue; 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -