Home Forums Feature Requests Set 'Post Title' from Field Group (Toggle) Reply To: Set 'Post Title' from Field Group (Toggle)

  • Hi all,

    This has been really useful for me. I’ve been trying to find a way to use an ACF field as a CPT title and this works nicely for me

    `* add custom slug and title */

    function my_post_title_updater( $post_id ) {

    if ( get_post_type( $post_id ) == ‘venue’ ) {

    $my_post = array();
    $my_post[‘ID’] = $post_id;
    $my_post[‘post_title’] = get_field( ‘venue_name’, $post_id );

    wp_update_post( $my_post );



    // run after ACF saves the $_POST[‘fields’] data
    add_action(‘acf/save_post’, ‘my_post_title_updater’, 20);

    A couple of quick questions …

    How can I concatenate two variables so that I can use ‘venue_name’ and ‘venue_city’?

    Also, how can I expand this to update the slug to use the same title ‘venue_name’ and ‘venue_city’? I currently have http://localhost:8888/gigs/venue/auto-draft/ as the slug.

    Thanks all.