Support

Account

Home Forums General Issues How to Modify Custom Field Settings Per Page?

Solving

How to Modify Custom Field Settings Per Page?

  • Here’s the scenario: I have a Field Group called “content layouts” and inside are some custom fields that will appear on a few different pages in my WordPress site. I’ve specified each of those pages by using the “page template is equal to” option under Rules.

    However, I want to have varying field group Settings for each page and can’t figure out how to do this. For example, one of the pages needs to show the editor while the others don’t. I also want the “content layouts” custom fields to appear above the editor on one page and below on another page.

    How can I apply unique field group Settings to each Rule defined inside my custom field group?

  • Update: I just noticed my ACF plugin had an update and includes a new “clone” field. I’m wondering if that might be the solution.

    Is it possible to reuse the same clone between multiple different field groups without creating a conflict?

  • You can’t alter the “Show on Page” or the location of the field group this way.

    You would need to:

    1) Create a different field group for each template

    2) If you’re using ACF5 Pro you could create a different field group for each template and use the new clone field to duplicate the fields

    3) Again, in ACF 5, there is a hook acf/get_field_group and you can add a filter to filter the field group when it is loaded.

    
    add_filter('acf/get_field_group', 'my_get_field_group_filter');
    function my_field_group_filter($field_group) {
      // modify group settings
      return $field_group;
    }
    

    Inside the filter you might be able to detect what page is being loaded and alter the group settings based on the page template. I am not 100% sure of this last option or the details on what you’d need to do here, it’s just a guess on my part. This filter may run before you can figure out what you need.

  • Thanks for the reply. I think the new clone field will work but I’m concerned about conflicts.

    Let’s say my base field group contains a flexible content field with the Name content_row. Is it ok if I then create multiple other field groups with a clone and name them all content_row_fields? Or would each clone also have to use a unique name?

  • As long as two field groups with the same field names are included on the same page editor, you should be fine. You will only run into a problem is you clone the same field to two field groups and then show both field groups in the same location.

  • So sorry to ask again but that’s a little confusing to read. Let me try to give a better example. Here are my main Field Groups with the field types and names:

    
    Content Layouts
    	Flexible Content (named: content_row)
    Home Page
    	Clone of content_row (named: content_row_fields)
    About Page
    	Clone of content_row (named: content_row_fields)
    Contact Page
    	Clone of content_row (named: content_row_fields)
    

    Since I’m using the same exact clone for the Home, About, and Contact page field groups, will those conflict?

  • No. The field groups are used on 3 different pages.

    Let’s look at an example that would be a problem.

    You create 2 field groups

    
    Content Layouts
    	Flexible Content (named: content_row)
    Home Page 1
    	Clone of content_row (named: content_row_fields)
    Home Page 2
    	Clone of content_row (named: content_row_fields)
    

    Now you set the location rules of these groups to both be on the home page. Now you will have a problem with conflicting field name.

  • Thank you! And last question: is it possible to make my “Content Layout” field group totally global? The issue I’m running into is I’m forced to add a Location Rule when creating that global field group but I don’t want to do that. I’d rather create the generic Content Layout field group without it applying to any specific pages/posts, and then using my other field groups (Home, About, etc.) to clone my generic Content Layout field group.

  • If you are only going to use a field group by making clones of it, set the group to inactive.

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

The topic ‘How to Modify Custom Field Settings Per Page?’ is closed to new replies.