in my theme option i created some options for sliders and other repeater option
in this way i limited to 1 slider per any sliders that exists .
so, i decide to migrate this options to custom post types for remove limitation and create unlimited of sliders and other repeater or elements .
is there a way for migrate options (max item is 1 per any slider or repeater) to custom post type programmatically ?
Are you wanting to move the data that you saved to those sliders to your custom post types? Or are you wanting to move the ACF fields you’ve created to the new custom post type?
If the former you could remap the data to the custom post types by using the
update_field() functions. Just loop through the old data, and remap the values to the new custom post type posts.
no no , my theme is now using by more than 500 customers .
for create unlimited numbers of any options, i move this options to custom post type .
and now i want prevent manual migrating by my customers and i want do it programmatically .
can you show me a way for doing it ?
If you use the methods above, you should be able to figure that out. You just need to loop through the data you have and remap it.
You can use WordPress’
wp_insert_post to create the new posts and then remap the fields using ACF’s
You’ll need to make sure those fields are set up for the custom post types via the ACF Admin before you can do the remapping.
@enter64 i don’t think it matters how ACF does it – you don’t need to copy the database structure over.
1. Set up the new fields for the custom post types
2. Loop through the old data you have stored
3. Create a new Post and remap that data
If you’re trying to just do a database migration, I think you’re over thinking the problem. Just remap, then delete the old data.
If you’re wanting to do this all via SQL, then I’ll have to defer to someone who has more expertise in that area.
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!
© 2022 Advanced Custom Fields.