Site icon Hip-Hop Website Design and Development

How can I save a Customized Submit Title and Slug with a Customized Subject?

I am utilizing Superior Customized Fields and I’ve Customized Submit Sort referred to as ‘recipe’.

I am utilizing this beneath code to set the customized put up title, based mostly on a customized discipline referred to as recipe_name:

operate my_post_title_updater( $post_id ) {

$my_post = array();
$my_post['ID'] = $post_id;

$recipe_name       = get_field('recipe_name');

if ( get_post_type() == 'recipe' ) {
  $my_post['post_title'] = get_field('recipe_name');
}

// Replace the put up into the database
wp_update_post( $my_post );

}
// run after ACF saves the $_POST['fields'] information
add_action('acf/save_post', 'my_post_title_updater', 20);

This above code works nice.. however I am attempting to additionally determine find out how to run the beneath operate as well as, however I am not seeing my put up slugs get up to date in any respect. They’re saving as “auto-draft-4” and is incrementing up from there.

operate slug_save_post_callback( $post_ID, $put up, $replace ) 
add_action( 'acf/save_post', 'slug_save_post_callback', 21, 3 );