Support

Account

Home Forums Backend Issues (wp-admin) Hiding Custom Field Groups but not removing?

Solved

Hiding Custom Field Groups but not removing?

  • Hi all,

    I created a system using a repeater field which has been used on over 300 posts, to make workflows better I redesigned it using the Flexible Content type.

    My only problem is I want to hide the old repeater fields so authors can’t use it but I want the information to still be pulled through on pages that did use it.

    Is there a way to hide it from future posts in the admin section but display it if it was used? I.e check to see if it contains data?

  • Yes, just change the location rules or make it inactive. The values in the fields will still be there and ACF will still return them with the standard front end function, get_field(), the_field(), have_rows(), etc.

    The you can do

    
    if (have_rows('old_repeater_field')) {
      // do one thing
    } elseif (have_rows('new_flex_field')) {
      // do the other thing
    }
    
  • This is good!

    Is there a way though, to show the fields in WP admin for posts that do have content in the old fields?

    That way it can be hidden for new posts but still be editable for old ones.

  • Not easily. You could move the field group to a file or php, figure out how to know which post is being loaded when you would normally add local field groups, then see if that post has any values and only add the local field group if it does. I’m sure it’s possible, but I can’t tell you exactly how without building it.

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

The topic ‘Hiding Custom Field Groups but not removing?’ is closed to new replies.