Support

Account

Home Forums General Issues priority issue with function Reply To: priority issue with function

  • Thanks @hube2! I completely understand, I changed my code to the following:

    //Auto add and update Title field:
    	
    	function my_post_title_updater( $post_id ) {
    
    	    $my_post = array();
    	    $my_post['ID'] = $post_id;
    
    	    $posttypes = array( 'post', 'portfolio', 'recensies', 'page' );
    	    $currentposttype = get_post_type();
    
    	    if ( in_array( $currentposttype, $posttypes ) ) { //only run if is certain post-type
    			if( $currentposttype == 'post' || $currentposttype === 'portfolio' || $currentposttype === 'page' ) {
    				$my_post['post_title'] = $_POST['acf']['field_56df22028f627'];
    			} elseif( $currentposttype === 'recensies') {
    				$my_post['post_title'] = $_POST['acf']['field_56dee620f84d5'] . ' (' . $_POST['acf']['field_56dee62cf84d6'] . ') - ' . $_POST['acf']['field_5734c3bcceb6c'];
    			}
    		    //Unhook function to prevent infitnite looping
    		    remove_filter('acf/save_post', 'my_post_title_updater', 1);
    
    		    // Update the post into the database
    		    wp_update_post( $my_post );
    
    		    //Rehook function to prevent infitnite looping
    		    add_filter('acf/save_post', 'my_post_title_updater', 1);
    		}
    
    	}
    	// run after ACF saves the $_POST['fields'] data
    	add_action('acf/save_post', 'my_post_title_updater', 1);
    

    now all my post_title updaters work, but my custom taxonomies are still not saved to the post, what are we missing here?