- This topic has 11 replies, 3 voices, and was last updated 7 months ago by
David.
-
AuthorPosts
-
June 18, 2020 at 3:06 am #1332396
Carsten
Hi there, I have created a Footer layout element and want to exclude BuddyPress pages.
The problem is that there is no such option for BP content in Display Roles?
June 18, 2020 at 6:19 am #1332586David
StaffCustomer SupportHi there,
you can use this filter:
https://docs.generatepress.com/article/generate_layout_element_display/
Just need to look up the relevant Template Tag that BuddyPress uses to set your condition.
https://codex.buddypress.org/developer/template-tag-reference/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 18, 2020 at 8:03 am #1332853Carsten
Thanks
I think this is the right tag
is_buddypress()
So it must be something likeadd_filter( 'generate_layout_element_display', function( $display, $is_buddypress() ) { if ( 10 === $is_buddypress()){ $display = true; } return $display; }, 10, 2 );
But where do I put in the code, there are no place to add code in a layout element?
June 18, 2020 at 9:02 am #1332958Leo
StaffCustomer SupportAdding PHP: https://docs.generatepress.com/article/adding-php/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 18, 2020 at 9:19 am #1332984Carsten
This question was, if I should use the footer layout element or not. If not, what about the other display rules I have added for the footer layout?
June 18, 2020 at 1:19 pm #1333261Leo
StaffCustomer SupportSorry not sure if I’m following.
If you are trying to add something to all buddypress pages then the layout element option sounds like the right way to go.
You can just leave the Display rules of that layout element empty and use the snippet instead.
Does that help?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 18, 2020 at 1:25 pm #1333268Carsten
My goal is to exclude all buddypress pages from displaying the footer
June 18, 2020 at 7:22 pm #1333444Leo
StaffCustomer SupportSo that case you need to create a layout element to disable the footer, then use the filter David suggested. The code should look something like this:
add_filter( 'generate_layout_element_display', function( $display, $element_id ) { if ( 10 === $element_id && BPCONDITION ) { $display = true; } return $display; }, 10, 2 );
You just need to replace
BPCONDITION
with the actual condition that suits your need.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 19, 2020 at 2:30 am #1333758Carsten
Thanks, I guess I have to change the $element_id with the actual element id, which is 32836?
Could I instead use generate_elements_show_object_ids
and insert this code and then add the BP pages inside the element using id’s?add_filter( 'generate_elements_show_object_ids', '__return_true' );
June 19, 2020 at 2:59 am #1333787David
StaffCustomer SupportYour filter PHP Snippet would look like this:
add_filter( 'generate_layout_element_display', function( $display, $element_id ) { if ( 32836 === $element_id && is_buddypress() ) { $display = true; } return $display; }, 10, 2 );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 19, 2020 at 3:23 am #1333809Carsten
Thanks a lot, it works perfectly, in future, I will remember how this is done.
June 19, 2020 at 4:09 am #1333866David
StaffCustomer SupportGlad we could be of help
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.