Home › Forums › General Issues › Location Rules – Category Page Template
I want different ACF Field Groups to show in the editor for different Category Page Templates, but I haven’t been able get this to work. It is the same concept as using the already defined Page Template, but for Category Pages.
Any help would be greatly appreciated.
I’m assuming that you’re using a plugin that let’s you assign templates to categories. You would need to build a custom location rule if this is the case.
http://www.advancedcustomfields.com/resources/custom-location-rules/
I have looked through the explanation, but it isn’t clear where the example code is supposed to be added.
Which file is this code being added to?
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices )
{
$choices['Basic']['user'] = 'User';
return $choices;
}
Ok, looks like I found where it goes:
wp-content\plugins\advanced-custom-fields\core\controllers\location.php
No, do not edit the ACF files.
You need to add the code you your functions.php file.
I’m going to be honest though. After giving this some thought I’m not sure it will work 100%. I don’t know what plugin you’re using for templates but its safe to say that it doesn’t use a standard wp field of any kind. This means that the field groups will not change automatically when you change templates. You would need to change the template and save the category to have them change.
No, still don’t see how it goes in that file.
The example really isn’t very clear at all as to where the different pieces of code are supposed to go.
The topic ‘Location Rules – Category Page Template’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.