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?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.