- This topic has 11 replies, 2 voices, and was last updated 4 years, 6 months ago by
David.
-
AuthorPosts
-
November 7, 2018 at 9:32 am #721437
joe@empathik.com
Sites I work on are very focused on page hierarchies. For example, these two sets of pages, each which would share certain layout elements:
Project A
/project-a/
/project-a/research
/project-a/research/something
/project-a/research/else
/project-a/capabilities
/project-a/contactProject B
/project-b/
/project-b/research
/project-b/research/something
/project-b/research/else
/project-b/capabilities
/project-b/contactIs there an option (existing, planned) in the Display Rules where, for example, you could set a header or a layout to appear on a parent page and all children (and even grandchildren).
Seems like this still needs to be done via custom function/PHP at this time.
Thanks in advance for your insight.
November 7, 2018 at 3:53 pm #721676Tom
Lead DeveloperLead DeveloperHi there,
I have a feeling this would be incredibly complex inside the Display Rules. There’s no plans for it right now, but I definitely wouldn’t rule it out for the future.
For now, I would just use the filters for each kind of Element to display them based on your specific conditions:
generate_header_element_display generate_hook_element_display generate_layout_element_displayExample usage: https://docs.generatepress.com/article/generate_header_element_display/
November 8, 2018 at 5:42 am #722057joe@empathik.com
Thanks, Tom, I certainly do appreciate your time and this project overall.
Just to make sure I’ve stated my intent clearly, this is similar to the Elementor conditions.
https://docs.elementor.com/article/311-conditions
Display Conditions
Include/Exclude: Singular > Page > Child of.
(There are a number of reasons why our NASA Glenn website customers don’t always need to go down the full-hog Elementor route.)
Thanks again for your time and consideration.
Adding for reference, the is_tree function I wish WordPress would add to core!
https://wordpress.org/ideas/topic/add-is_tree-function-to-core-of-wordpressNovember 8, 2018 at 9:47 am #722378Tom
Lead DeveloperLead DeveloperThanks for that! I’ll take a look at how they achieved it 🙂
November 14, 2018 at 9:56 pm #727686David R
This is exactly what I need, too. Case use: staff bio pages where the staff Position is a custom field with an Element to display the custom field under the title. My current workaround is to Display > All Pages with PHP to filter for the ancestor page id. Main Staff Page (ID: 44) > Individual Staff Bio Pages:
$post_id = get_the_ID(); $ancestors = get_ancestors( $post_id, 'page'); if($ancestors[0]==44) {...};With the Child Of display rule, this could then be done in a Page Header with the {{custom_field.name}} tag without the filter.
Also, a similar function in WP Show Posts where you can create a list of all children (I had previously mentioned this too you in email on 3/19/2018). Currently I just manually enter the individual Page IDs, but that’s tedious for maintenance as pages are added/removed. Same case use as above, where the same custom field is inserted into the list with a WP Show Post Code Snippet.
[Staff (ID: 44) lists the staff name and Position, then click-thru to the individual bio page for details.]
There is the get_children() function, but I can see how that can get cumbersome with recursion. With an Elements Display > Child Of, I can see a lot of iterations to check every page and determine if a display rule applies: get_ancestors(get_the_ID()) and determine if the given Parent ID on each Element with a Child Of rule exists for the current Page ID.
August 9, 2019 at 8:26 pm #980407Dario
I’m new to GeneratePress, and loving it so far!
Is there any new development on having an “element” for displaying a list of child pages? Preferably with the featured image?
Thanks much.
August 10, 2019 at 6:54 am #980564David R
WP Show Posts Pro doesn’t do child lists yet, but the workaround is to use a plugin like Add Category to Pages, then creating a list with that Page Category. This works just as well as a child page list would for me; I just have to be sure to assign the Pages to the Category.
August 10, 2019 at 9:47 am #980795Tom
Lead DeveloperLead DeveloperNo news on the child pages, yet, but it’s still something we’re planning on doing.
Adding categories to pages is super useful when it comes to the Display Rules 🙂
August 11, 2019 at 4:05 pm #981626Dario
Thanks for the replies and ideas. I ended up creating a custom post type and archive page instead to display all the items.
August 11, 2019 at 5:14 pm #981646Tom
Lead DeveloperLead DeveloperAwesome 🙂
September 27, 2021 at 7:18 am #1944361Fabien
Hi @Tom, any updates on this ?
Thanks
September 28, 2021 at 6:20 am #1945488David
StaffCustomer SupportNot yet. We’re currently reviewing the Display Rule mechanisms as a whole part of which would consider child pages and other methods of selection.
-
AuthorPosts
- You must be logged in to reply to this topic.