Home › Forums › General Issues › Subheadline Text Delayed when Publishing? › Reply To: Subheadline Text Delayed when Publishing?
Ok, so the below code no longer causes the conflict, but is still requiring me to do the double update which is back to where we started:
// Custom URL Post Title
function custom_url_post_title($data , $postarr) {
if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
$custom_field_title = get_post_meta($postarr['post_ID'], 'heading2', true);
if(isset($custom_field_title) && $custom_field_title != '')
$data['post_name'] = sanitize_title($postarr['post_title'].'-'.$custom_field_title);
}
return $data;
}
add_action ('wp_insert_post_data','custom_url_post_title', 99, 2 );
// End Custom URL Post Title
// Custom ACF
function custom_post_title( $value, $post_id, $field )
{
// update the $post via the wp_update_post function
return $value;
}
// acf/update_value/name={$field_name} - filter for a specific field based on it's name
add_filter('acf/update_value/name=heading2', 'custom_post_title', 10, 3);
// End Custom ACF
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.