Site logo

Archived topic

Block elements just don't like BP pages

26 replies · Started by Carsten on October 16, 2020

Viewing posts 1–15 of 27

I thought this was solved, but it's not, Block element content is not displayed on BuddyPress pages, this time the Activity page.

https://imgur.com/bbddloE

Thanks for looking into this.

Hi there,

where can i see the Activity page ?

Hi there, the activity page is the landing page when you login.

Thanks

So i am seeing the 'secondary' container with the Visits and Messages elements in the secondary nav .... whats missing?

If I change the location to entire site it will show up

I am seeing another body class of directory on that page. Is Directory a location option in the elements ?

In the Body classes you can see before activity - which is the page slug you're currently using there is the directory class - In the Element > Display Rules - is Directory a location eg. Directory > Activity or Pages > Directory for example.

It's possible that the BP pages don't think they're static pages, so those rules wouldn't work.

What David is saying is when you look through the Display Rules, do you see any rules that reference Directory?

When you say you thought this was solved - what steps were taken to solve it in the first place?

Hi there, I have earlier posted a topic about elements not working with BP pages, at that time, it was the /register page which was the problem. At that time you said it was something you would look into, if there was an easy solution.

Makes sense, I don’t believe BuddyPress uses conventional WordPress conditions (as funny as that is), so our Display Rules aren’t aware of their specific conditions/rules when it comes to displaying.

We’ll see if it’s something easy enough to add compatibility with.

https://generatepress.com/forums/topic/block-element-is-not-displaying/

Therefore I waited for a solution, but of course, I could not expect it to be solved.

The pages /register and /activity are listed in the element, so I expected the block element to work in these pages.

Regards
Carsten

Ah, it's as I said - BP isn't using the conventional conditions.

You'll have to do this:

add_filter( 'generate_block_element_display', function( $display, $element_id ) {
    if ( 123 === $element_id ) {
        if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
            return true;
        }
    }

    return $display;
}, 10, 2 );

Then you just need to update 123 with the ID of the Element and it should work.

Hi there, thanks for bringing up a solution.

Apparently the code is not working, using the post=42208, which I assume is the id of the element.

I inserted this into the code snippet and added it to my functions.php file, any idea why it should not work with the /activity page?

add_filter( 'generate_block_element_display', function( $display, $element_id ) {
    if ( 42208 === $element_id ) {
        if ( function_exists( 'bp_is_activity' ) && bp_is_activity() ) {
            return true;
        }
    }

    return $display;
}, 10, 2 );

Thanks!

Hmm, instead of this:

if ( 42208 === $element_id ) {

Try this:

if ( 42208 === (int) $element_id ) {

Any difference?

This archived topic is closed to new replies.