Home › Forums › Backend Issues (wp-admin) › Unable to add fields/existing fields disappeared › Reply To: Unable to add fields/existing fields disappeared
I had the below code in my functions.php file and after removing it the problem seems to have gone away (as in I can now create fields without them disappearing, the Field Group that had the fields who disappeared in it is still empty, but I will rebuild and now see that the content still lives in the database). The below code was to take some text from an ACF and change the slug of the post to that text.
add_action('save_post', 'change_default_slug');
function change_default_slug($post_id) {
//Check it's not an auto save routine
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return;
//Perform permission checks! For example:
if ( !current_user_can('edit_post', $post_id) )
return;
//Check your nonce!
//If calling wp_update_post, unhook this function so it doesn't loop infinitely
remove_action('save_post', 'change_default_slug');
// call wp_update_post update, which calls save_post again. E.g:
wp_update_post(array('ID' => $post_id, 'post_name' =>get_post_meta($post_id,'request_number',true)));;
// re-hook this function
add_action('save_post', 'change_default_slug');
}
Interested to hear why this might have caused a conflict, but grateful that the problem is gone!
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.