Support

Account

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