Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wonder if anyone can help me, I am trying to display excerpt and thumbnail for the posts shown in the buddypress blog directory page. By default only avatar thumb and title link to the posts are shown.

I have created a function based on the function bp_blog_latest_post() used in the blogs loop but I am not sure how to proceed. I can see that the blog template class is accessed but don't know how to access further information, if this is not possible then do I need to use the buddypress excerpt filter as well? Here is the slightly customised function so far..

<?php

function bp_blog_latest_post_excerpt() {
    echo bp_get_blog_latest_post_excerpt();
}

function bp_get_blog_latest_post_excerpt() {

    //global variable carying data used in blog templae
    global $blogs_template;
    //if no posts then return nothing (and default to message I assume)
    if (null == $blogs_template->blog->latest_post)
        return false;
    //otherwise..
return apply_filters( 'bp_get_blog_latest_post', apply_filters( 'the_excerpt', $blogs_template->blog->latest_post->post_excerpt) );
}
?>
share|improve this question
add comment

1 Answer 1

I don't have a complete answer for you. But I can point out that you should use the filter hook provided in the function bp_blog_latest_post()

So something like:

add_filter('bp_get_blog_latest_post', 'your_function', 1);
function your_function(  ) { 
   global $blogs_template;

   $str = // build your string to include excerpt and thumbnail

   return $str;
}

I don't recall if bp_blog_latest_post() is called anywhere other than the blog directory page - if it is, then this approach will change that too.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.