Home › Forums › Support › Display Elements via filters This topic has 3 replies, 2 voices, and was last updated 4 years, 5 months ago by Tom. Viewing 4 posts - 1 through 4 (of 4 total) Author Posts December 21, 2018 at 12:15 pm #763252 melanie I have several custom headers (elements) that I would like to display via filters vs. adding a long page list. I wrote the function but something must be wrong. Any pointers? //Apply Custom Page Header based on Ancestor add_filter( 'generate_header_element_display', function( $display, $element_id ) { if ( 45458 === $element_id && is_array( $ancestors ) && in_array( 44258, $ancestors ) ) { $display = true; } return $display; }, 10, 2 ); December 21, 2018 at 5:48 pm #763370 TomLead Developer Lead Developer Hi there, You don’t seem to have anything defined as $ancestors. Are you trying to target a list of regular pages, or a list of child pages to a specific parent page? December 26, 2018 at 12:50 pm #766136 melanie A list of child pages to an ancestor. The ancestor being page ID 44258. Thanks Melanie December 26, 2018 at 9:50 pm #766340 TomLead Developer Lead Developer In that case, I think you’d do this: add_filter( 'generate_header_element_display', function( $display, $element_id ) { $children = get_children( array( 'post_parent' => 44258 ) ); if ( 45458 === $element_id && ! is_empty( $children ) && is_singular( $children ) ) { $display = true; } return $display; }, 10, 2 ); Author Posts Viewing 4 posts - 1 through 4 (of 4 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In