Home › Forums › Front-end Issues › Update post without changing its title › Reply To: Update post without changing its title
Hi @mastafu
I think you could just do a check for the title value in your save_post hook and ignore the changes if it’s empty.
add_action( 'acf/save_post', 'my_update_existing_post_data', 10 );
function my_update_existing_post_data( $post_id ) {
if(!isset($_POST['acf']['field_5464a2a2d9a50']) || $_POST['acf']['field_5464a2a2d9a50'] == '')
return;
// Update existing post
$post = array(
'ID' => $post_id,
'post_status' => 'publish',
'post_title' => wp_strip_all_tags($_POST['acf']['field_5464a2a2d9a50']), // Post Title ACF field key
);
// Update the post
$post_id = wp_update_post( $post );
}
Let me know how that works!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.