Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Add post featured image in activity stream

@matt-mcfarland

Participant

Yes this is very easy to do.

Adding the featured image of a wordpress post into a buddypress activity stream can be done by doing one of the following. I’d like to add that I had trouble finding out how to do this at first and it took a lot of searching. The first copypasta I have for you was actually found on these very forums. However, due to so many people asking this question (and not getting answers) it is buried and very difficult to find. So without further ado please enjoy…

You can either edit the activity page activity/entry.php or just copy paste the following function into your functions.php file.


function icondeposit_bp_activity_entry_meta() {
 
    if ( bp_get_activity_object_name() == 'blogs' && bp_get_activity_type() == 'new_blog_post' ) {?>
        <?php
        global $wpdb, $post, $bp;
        $theimg = wp_get_attachment_image_src(  get_post_thumbnail_id( bp_get_activity_secondary_item_id() ) );
        ?>
        <img src="<?php echo $theimg[0]; ?>" >
 
    <?php }
 
}
add_action('bp_activity_excerpt_append_text', 'icondeposit_bp_activity_entry_meta');

If you want further customization, I recommend editing activity/entry.php

Skip to toolbar