Can you tell me what is the correct way to change CPT “post type/taxonomy key? Iam testing stuff out, I did the following and I see some strange behavior.
I created my CPT lets say “dog” with ACF6.23 dint use the advanced settings,
next I added some dummy posts inside my new cpt.
I went back to the “dog” CPT settings and changed the “post type key” from “dog” to “dog-something”
When I did that all the dummy posts inside my admin Dog Cpt dissapeared.
I tried resaving permalinks – didnt help. When I changed “post type key” back to “dog” they all reappeared on the post list.
It looks like these post are still somewhere in the database only hidden for some reason?.
Iam curious to why this is happening or what did I do wrong?
Thank you for you help!
You cannot change a post type name once posts have been added. WP saves this information in the post table and there isn’t a way to change this if you changes the post type name/slug.
CPT-UI has a feature to migrate posts, but it is not something I would use on an active site with a lot of posts.
If you are looking for a similar feature in ACF
Hi John, thanks for quick response!
Ok I get it. So the best practice here would be to plan you sites URL structure ahead of adding content even if its only local dummy content that helps me see what Iam building.
Is there a way to change/update those slugs by running search replace on the database itself?
yes there is, someone else commented on this but it was marked as spam because they included a spammy link. It’s sad when people who actually have knowledge post useful information only because they want to inject a link to some unrelated site. In all likelihood these people are now generating what appears to be useful information with AI. I do not put up with spam here.
UPDATE wp_posts SET post_type = 'dog-something' WHERE post_type = 'dog'
This should be done with caution, like backing up your DB first.
Yes, you should plan ahead. Test a little if you want, but I would not change a CPT or custom Taxonomy name after live content is added. Especially if there is a lot of posts.
You must be logged in to reply to this topic.
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!