-
Michel
Hello Tom & Co.
I have created 2 different footers in Elements, including display rules (footer 1 on the whole page except page X, footer 2 on page X) Works fine. But I want footer 2 to be displayed on all subpages of page X as well. How can I achieve this? Filter?
I have already done something similar in a hook for showing different navigations:
<?php if (wpdocs_is_tree(Site ID)): ?>
<div>block 1</div>
etc.
Kinda like this ?
Thanks for helping.
Greetings -
Hi there,
you can use the
generate_element_display
filter hook.
See here: -
Michel
Thank you for the quick reply.
That’s how it works, but now all subpages of page X are displayed with both footers (footer 1 and footer 2).
Have I forgotten something? -
You would use a second filter to unset the the other element.
Just set the ID to the other element and set the$display = false;
eg.
add_filter( 'generate_element_display', function( $display, $element_id ) { global $post; if ( 1180 === $element_id && ( is_page() && $post->post_parent == '415' ) ) { $display = false; } return $display; }, 10, 2 );
-
Michel
php isn’t my strength 😉
Thank you very much. -
Glad to be of help
- You must be logged in to reply to this topic.