Home Forums ACF PRO Changing custom fields from page to custom post type


Changing custom fields from page to custom post type

  • I’m pretty new to using ACF (in fact WP in general).

    I have lots of event pages, based on my event template, for various schools. The pages all have a custom field group, with repeater field, and I’ve spent a lot of time on dat entry for all of this.

    Now I’d like to use a custom post type for the events and want to try to save myself from having to perform tons of data entry again.

    I’ve searched the forum and search engines for help but I can’t find a solution. I’m sure this must be something that isn’t too unique so maybe my search queries are too vague.

    Is it possible to do?

  • Hi @mattrobinson

    Hmm… The easiest way would be to write a PHP script to transfer the values from the old post the new post. The code would be something like this:

    $field_key = '<field_key>'; // replace this with the actual field key
    $old_post_id = <old_post_id>; // replace this with old post id
    $new_post_id = <new_post_id>; // replace with new post id
    // first get value from the old post
    $value = get_field($field_key, $old_post_id);
    update_field($field_key, $value, $new_post_id); 

    Hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Changing custom fields from page to custom post type’ is closed to new replies.