Site logo

[Resolved] Display Rules for Child Pages

Home Forums Support [Resolved] Display Rules for Child Pages

Home Forums Support Display Rules for Child Pages

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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/contact

    Project B
    /project-b/
    /project-b/research
    /project-b/research/something
    /project-b/research/else
    /project-b/capabilities
    /project-b/contact

    Is 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.

    #721676
    Tom
    Lead Developer
    Lead Developer

    Hi 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_display

    Example usage: https://docs.generatepress.com/article/generate_header_element_display/

    #722057
    joe@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-wordpress

    #722378
    Tom
    Lead Developer
    Lead Developer

    Thanks for that! I’ll take a look at how they achieved it 🙂

    #727686
    David 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.

    #980407
    Dario

    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.

    #980564
    David 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.

    #980795
    Tom
    Lead Developer
    Lead Developer

    No 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 🙂

    #981626
    Dario

    Thanks for the replies and ideas. I ended up creating a custom post type and archive page instead to display all the items.

    #981646
    Tom
    Lead Developer
    Lead Developer

    Awesome 🙂

    #1944361
    Fabien

    Hi @Tom, any updates on this ?

    Thanks

    #1945488
    David
    Staff
    Customer Support

    Not yet. We’re currently reviewing the Display Rule mechanisms as a whole part of which would consider child pages and other methods of selection.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.