Support

Account

Home Forums ACF PRO Renaming template and keep ACF data?

Solving

Renaming template and keep ACF data?

  • Hello,

    I’m tackling a project where WordPress standards are highly valued and I MUST change templates’ file names following WordPress standards.

    This will result in loosing ACF data.

    I’m wondering if there is some sorts of SQL that can help me update the template name.

    Following this article, I can update template name for all pages: http://wordpress.stackexchange.com/questions/57568/how-to-rename-a-template-file

    UPDATE wp_postmeta SET meta_value = ‘new-filename.php’ WHERE meta_value = ‘old-filename.php’;

    But not ACF…

    Many thanks,

  • Hi @ndh611

    Actually, you will not lose any ACF data should you rename your template files.

    Hmm… May be you can elaborate further on your field setup so that I can be able to assist.

  • Sorry I did not make it clear.

    For example I have field group FG-A, setup for Page Template page-a.php
    I need to change page template name to page-awesome.php

    After changing that, in Custom Fields tab, field group FG-A does not apply for this template anymore, so I gotta do that manually again, and even go to check pages (with template page-awsome.php) to see if this still works.

    Is there any kinda SQL query to fix this all at once, instead of manually doing this for every single field group (which this website has a lot)

    For pages, this is what we did:
    UPDATE wp_postmeta SET meta_value = ‘page-awesome.php’ WHERE meta_value = ‘page-a.php’;

    But this did not solve ACF thing above ๐Ÿ™‚

    Thanks

  • Hi @ndh611

    Thanks you for the clarification. ACF saves the field group settings in wp_posts table in the DB. So should you wish to do a DB query to update the template, this should work:

    UPDATE wp_posts SET post_content = REPLACE( post_content , 'page-a.php', 'page-awesome.php' ) WHERE post_type = 'acf-field-group'

    Give this a try and let me know if your issue gets resolved ๐Ÿ™‚

  • Thanks James, we will try right away. I really appreciate your help.

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

You must be logged in to reply to this topic.