Activity content outside the loop, in the head?
-
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?
-
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
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?
I’ll post some code later to show you how to get info.
Thanks a lot!
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
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)bp_is_single_activity() <- was looking for that
Maybe I should just add this the BP share it
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!
- The topic ‘Activity content outside the loop, in the head?’ is closed to new replies.