Thanks. This is exactly what I’m looking for.
But it would be good if such a feature was available out of the box.
I found a little bug in the example you’ve provided. There’s a typo:
isset($option['post_id'] instead of
// Edit 2;
I’ve found another bug.
$page_level doesn’t return a correct value.
The logic is overcomplicated. It could be simplified:
$page_level = count(get_post_ancestors($options['post_id'])) + 1; works fine.
One more comment:
There’s one disadvantage of this solution.
acf/location/rule_operators filter doesn’t allow to set operators for a specific rule. It’s a general filter that applies for all the rules. But as far I know there’s no other option at the moment.
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!
© 2022 Advanced Custom Fields.