Skip to content

update key/name for specific post types? #1

Description

@adaptifyDesigns

Hi, thanks for maintaining a great ACF solution script!

I am updating a website where there is currently an ACF field group which is applied to several different custom post types, but now I will be using the acf_add_local_field_group function to dynamically create similar field groups, and applying each unique field group to each unique custom post type.

For example, there used to be a field with:

$field = array(
    key => 'field_a8t092sthaoer7',
    name => 'some_awesome_field',
);

And this field is used by 4 post types: 'books', 'movies', 'tv-shows', and 'video-games'.

Now there will be the following 4 fields:

$books = array(
    key => 'field_books_some_awesome_field',
    name => 'books_some_awesome_field',
);

$movies = array(
    key => 'field_movies_some_awesome_field',
    name => 'movies_some_awesome_field',
);

$tv_shows = array(
    key => 'field_tv-shows_some_awesome_field',
    name => 'tv-shows_some_awesome_field',
);

$video_games = array(
    key => 'field_video-games_some_awesome_field',
    name => 'video-games_some_awesome_field',
);

And each of the above fields will be used only by their corresponding post type.

I'm wondering if your script can target a specific post type when updating keys and field names.

If not, perhaps you could point me in the right direction to figuring this out. I'm fairly proficient with PHP, but have never done any direct database manipulation. Any help is much appreciated.

Cheers!
Colin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions