Archived topic
Exclude BuddyPress members page from Page Hero block element
7 replies · Started by Cheryl on August 11, 2022
Hi,
I have a GP block element that is a page hero that gets applied to most pages on my site.
However, I do NOT want it on BuddyPress pages. I tried excluding the page itself -- excluding it from the login page worked, but the main BP page /user/ has many child pages and if I exclude Page:User the page hero remains on the user page and all of its children.
Is there a way I can exclude a block element from all BuddyPress pages?
Thanks
Hi Cheryl,
Can you try this snippet? Replace 951 with the element's ID, and 77 with the parent page ID.
add_filter( 'generate_hook_element_display', function( $display, $element_id ) {
global $post;
if ( 951 === $element_id && ( is_page() && $post == post_parent > 77 || is_page(77)) ) {
$display = false;
}
return $display;
}, 10, 2 );
Let me know if this works.
No, unfortunately, that didn't do it. I saw a snippet like that in another post in the forum here and had tried it.
I've tried excluding the member page, the groups page, and the register page this way and it doesn't work. Neither does excluding those pages on the Page Hero element itself.
I suppose I could INCLUDE the page hero only on select pages but that would be very cumbersome and take a lot of time. But as a last resort, I could do it...though it would be nice if there were a way to exclude it from any BuddyPress page.
Somehow, excluding the Buddypress login page in the element DOES work and removes the page hero element there.
Thanks.
Hi there,
try this snippet:
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 10 === $element_id ) {
if ( function_exists( 'is_buddypress' ) && is_buddypress() ) {
return false;
}
}
return $display;
}, 10, 2 );
Change the 10 to the ID of the Element.
This should disable that element wherever Buddypress templates are loaded.
Hi,
Thanks for the snippet. Unfortunately, that also did not work. I also found and tried the snippet to exclude the element from pages that have the featured image disabled. That also did not work in this case.
But I went ahead and added some CSS to move the box around the membership page fields up so they overlap the blank page hero. This looks good enough to me.
Thanks again for the help.
Doh -- i made a mistake in the Code here:
just updated that if you want to give it another go.
That worked beautifully! Thanks!
Cheryl
Glad to hear that!