Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Parent Page Type Check
-
So first. Love ACF.
I have a suggestion for your location rules. Currently your plugin's location rules will return true as a parent page for any top level page. So your current parent check will output field groups the same as your post type = page (a bit of a redundancy). But I would argue that a parent page is only a parent when it has child pages. So my suggestion would be to replace your location rule for the parent type. I'm using this on line 1314 of acf.php:
if( $rule['value'] == 'parent')
{
$post_parent = wp_list_pages( 'echo=0&child_of=' . $post->ID . '&title_li=' );
if( isset($overrides['page_parent']) )
{
$post_parent = (int) $overrides['page_parent'];
}
if( $rule['operator'] == "==" )
{
if( $post_parent )
{
return true;
}
}
elseif( $rule['operator'] == "!=" )
{
if( !$post_parent )
{
return true;
}
}
return false;
}
Now there may be a better way of doing this check but it corrects the logic as I think it should. Anyway, thanks so much for all your hard work.
- ben -
Hi @bluoma
A god suggestion. I'll have a think about this one.
The only problem I can see is that some people's field groups will not show up based on their previous location rules...
Cheers
Elliot -
I agree. I suggestion from God ;-)
I wonder how many users would find this useful. Perhaps a type of "Has Child" could be added. Maybe there could be a way to hook into this so additional location rules could be added via theme functions.
thanks Elliot
- ben -
Hi @bluoma
Yep, I think a new rule for has child would allow for a seamless integration with previous data!
Great idea, I'll add it to the to-do -
Hi @bluoma,
The logic for "Parent Page" has been updated to only return true if the page in question has children, not just if it is a top level page.
This will be included in the next version 3.5.4
Cheers
Elliot -
This discussion has been closed.
All Discussions 