Site logo

Archived topic

No option for excluding BP content in Footer Layout Element Display Roles

11 replies · Started by Carsten on June 18, 2020

Viewing posts 1–12 of 12

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?

Thanks

I think this is the right tag is_buddypress()
So it must be something like

add_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?

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?

Sorry 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?

My goal is to exclude all buddypress pages from displaying the footer

So 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.

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' );

Your 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 );

Thanks a lot, it works perfectly, in future, I will remember how this is done.

Glad we could be of help

This archived topic is closed to new replies.