Home › Forums › Feature Requests › Top level location rule
Hello!
In ACF pro there is a location rule “Parent page”.
Currently i have to create multiple rules for three levels of navigation.
Example:
– level1
— level2
—- level3
I need to add ACF fields to all pages under -level1. Currently this is not possible because i can only use “Page parent” rule that reaches to only –level2 pages.
Can you please add Top level option too so that every page that is under -level1 will get fields?
I recently helped someone else create a location rule for page grandparent, you can find it here http://support.advancedcustomfields.com/forums/topic/custom-location-rule-to-select-grandparent-page/
Yes! Thanks!
But, will it be integrated to the plugin?
And what if i have for example 6 levels deep menu. Can you modify this code to take 1 level page as a guide?
I’m not the developer of this plugin, I just use it a lot and help out on these forums. While the developer is free to incorporate these into the plugin I can’t say if that will happen or not.
There is a built in location rule for Parent Page and I have two custom location rules, one for grandparent page and the other for ancestor page. The ancestor page will put a field group on any descendant of the selected page. That’s probably as far as I’m going to do with this. The grandparent code could be easily modified to target specific depths.
I’ve put both of these up on github
Grandparent: https://gist.github.com/Hube2/fe445cdec6dd498af48a
Ancestor: https://gist.github.com/Hube2/27b7f4159b15b0447cad
Appreciate this is very old, but this code still works and I just wanted to say thank you this is fantastic! It would be great to have it in the core, even if just to prevent custom code breaking in the future. Still works now though! Thanks
The topic ‘Top level location rule’ 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.