[Resolved] Element set visibility on all pages with a specific page parent

Home Forums Support Element set visibility on all pages with a specific page parent

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1438353
    Matthew

    Hi

    Is it this possible? I don’t think it is unless I have missed something?

    So basically if 20 pages have a parent page called “123” set an element to appear on all pages with the parent “123”?

    If its not possible I would love to suggest this as a feature. 😀

    Cheers

    #1438356
    Leo
    Staff
    Customer Support
    #1439338
    Matthew

    That is fantastic Leo!

    Just a quick one though, to avoid just duplicate this code, how could I have an element load on multiple parents/childs?

    E.g. say the element ID is 1180 (like in the example) and I want this to load on child for 415 and 420 (random examples).

    I assume this is fairly simple if you know what you are doing, I do not. Haha.

    #1439546
    Leo
    Staff
    Customer Support

    It would be something like this:

    add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
        global $post;
    
        if ( 1180 === $element_id && ( is_page() && $post->post_parent == '415' ) || 1180 === $element_id && ( is_page() && $post->post_parent == '420' ) ) {
            $display = true;
        }
    
        return $display;
    }, 10, 2 );
    #1439728
    Matthew

    Awesome thank you 🙂

    #1439927
    Leo
    Staff
    Customer Support
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.