Home › Forums › Backend Issues (wp-admin) › Unable to add fields/existing fields disappeared › Reply To: Unable to add fields/existing fields disappeared
The problem is that your filter runs on all post types. ACF field groups work just like any other post type and ACF uses itself to save the fields the same way that it saves values for our custom fields.
At any rate, what you need to do is make sure you’re only doing this on the post types you need it to happen on.
add_action('save_post', 'change_default_slug');
function change_default_slug($post_id) {
if (get_post_type($post_id) != 'your-post-type') {
return;
}
//Check it's not an auto save routine
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return;
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.