Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity content outside the loop, in the head?


  • diniscorreia
    Member

    @diniscorreia

    Hi there,

    I’m fairly new to BuddyPress so I’m still trying to figure some things out.

    I’m trying to write meta tags to the of the page (OpenGraph and Twitter Cards); however, I can’t seem to find a way to grab the content of an activity entry (body and title). I can do this easily on WordPress so I was expecting to be able to do so with BuddyPress.

    Any ideas?

Viewing 9 replies - 1 through 9 (of 9 total)

  • modemlooper
    Moderator

    @modemlooper

    Not going to work well, I’ve tried to incorporate open graph in BP Share it plugin. The open graph can be used on an activity’s permalink page. It will not work properly inside the activity loop. Permalink.php is like single.php. You can add open graph to that file


    diniscorreia
    Member

    @diniscorreia

    Thanks for the quick reply!

    That’s exactly what I want – only on the permalink page. But the OpenGraph tags are supposed to go in the “, so I can get the activity single entry content there?


    modemlooper
    Moderator

    @modemlooper

    I’ll post some code later to show you how to get info.


    diniscorreia
    Member

    @diniscorreia

    Thanks a lot! :)


    modemlooper
    Moderator

    @modemlooper

    You could create another loop in the head,

    `

    <meta property="og:description" content="”/>

    `

    The only problem is you would want this to be only on the permalink header. You could duplicate header.php and call it header-permalink.php and then call that header in the permalink.php file


    r-a-y
    Keymaster

    @r-a-y

    You could also wrap modemlooper’s code with a few conditionals:

    `<?php
    // see if the activity component is active and if we’re currently on an activity permalink page
    if ( bp_is_active( ‘activity’ ) && bp_is_single_activity() ) :
    // add our mini activity loop
    if ( bp_has_activities( ‘include=’ . bp_current_action() ) ) :
    while ( bp_activities() ) : bp_the_activity();
    ?>

    <meta property="og:description" content="”/>

    <?php
    endwhile;
    endif;
    endif;
    ?>`

    This can also be turned into a tiny plugin, so if you don’t like adding huge chunks of code into your header.php, you could hook into the ‘bp_head’ action:
    http://pastebin.com/CPAk4D16 (paste the following into wp-content/plugins/bp-custom.php)


    modemlooper
    Moderator

    @modemlooper

    bp_is_single_activity() <- was looking for that :D


    modemlooper
    Moderator

    @modemlooper

    Maybe I should just add this the BP share it


    diniscorreia
    Member

    @diniscorreia

    Geez guys, thank you *so* much :)

    @modemlooper haven’t installed your plugin, but if it shares on Facebook, you totally should add it.

    Again, thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Activity content outside the loop, in the head?’ is closed to new replies.
Skip to toolbar