Support

Account

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

  • Hi guys, firstly thank you for providing your solution to this – I’m trying to do the same thing but I need to use an ACF field’s related taxonomy in the Post Title…

    When I implement your code @andycheeseman I can pull in the ID of the field I want, but not the Object. I have tried setting the Return Value in the field’s settings to Term Object rather than Term ID but I still get the ID.

    For reference this is the code I am using:

    function my_post_title_updater( $post_id ) {
    
    	if ( get_post_type() == 'match' ) {
    
    		$my_post = array();
    		$my_post['ID'] = $post_id;
    		$my_post['post_title'] = get_field( 'home_team', $post_id );
    		
    		// Update the post into the database
    		wp_update_post( $my_post );
    
    	}
    
    }
    
    // run after ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'my_post_title_updater', 20);

    `

    Any help on how to get the taxonomy values from an ACF field would be much appreciated!!

    Thanks 🙂