Hi Michael
if i understood your question you simply want a list of topics in your forum like bbpress.org/forum! am i right?
Hi mostafaghanbari — not exactly like that, the home page of this forum just shows the topics, an not the text in the topics and replies.
I want to display an excerpt of the most recent N topics and replies across all forums/topics. Think of it as just displaying the first 100-200 characters of member posts. This will go on the home page of my site in a small box, and in a sidebar on various pages on the site.
Does that make sense?
Michael
Here’s an example of what I’m trying to generate. This requires access to: Topic name, most recent Topic post/reply, name of the member posting, and his avatar.
http://www.dalluva.com/temp/example-excerpt-block.JPG
In this example (which I mocked up in PowerPoint), it is showing the 3 most recent bbPress posts across 3 different Forums/Topic areas.
I hope that makes it clearer as to what I’m trying to accomplish.
Thanks.
Michael
-
This reply was modified 12 years, 1 month ago by Michael.
Okay, I’ve made some progress with this, though it’s not quite where I want it to be. I’ve been playing around with the function calls in bbp-topic-template.php, and been able to create a block of code that creates excerpts of topics (though not replies to topics…yet).
Here’s the resulting output: http://www.dalluva.com/temp/example-excerpt-block-getting-there.JPG
And here’s the code block (so far):
$max_shown = 3;
$parent_forum = 'any';
$excerpt_length = 200;
$avatar_size = 60;
$topics_query = array(
'author' => 0,
'post_type' => bbp_get_topic_post_type(),
'post_parent' => $parent_forum,
'posts_per_page' => $max_shown,
'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ),
'show_stickes' => false,
'meta_key' => '_bbp_last_active_time',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array( bbp_exclude_forum_ids( 'meta_query' ) )
);
$topic_query = new WP_Query( $topics_query );
if ( $topic_query->have_posts() ) :
$first_time = 1;
?>
have_posts() ) :
if ( $first_time == 1 ) : $first_time = 0;
else : echo "" ;
endif;
$topic_query->the_post();
$topic_id = bbp_get_topic_id( $topic_query->post->ID ); ?>
<a class="home-topics-a" href="" title="">
In Forum ""
By , Posted about
<a class="home-topics-more more" title="Join the Conversation" href=""> READ MORE
<?php
endif;
I'm going to keep working this and I'll post my final results in the coming days. Any comments/input are appreciated. Cheers. Michael
It looks like the editor munged my code, so here’s a pointer to the code (in a .txt file): http://www.dalluva.com/temp/topic-excerpt.txt
Cheers.
Michael
well done michael! it looks like you did it! but i think there is a more simple way to do so(lets say another way instead of an easy way because your way is not difficult also!). when you install bbpress you can go to yoursite/topics and see list of all topics. in this page you can see similarities with items that you really need:
http://dl.dropbox.com/u/65583116/topics1.JPG
the only thing you need to do is find out what file in bbpress do this job. the file is:
loop-single-topic.php
and here is the codes related to what we want:enter link description here
and finally the last thing is having a summary of topic content. that’s i dont know it yet! 😀
Where can I insert this long code? I’m beginner in bbpress 🙁
none of the links provided work. Can anyone re-supply the excerpt information for loop-single-topic please?
@nolimit966 i think you can use <?php bbp_topic_excerpt(); ?>
place this in loop-single-topic.php and you should see it.
Thanks for the reply Robkk, i just tried using that but its not displaying anything at all.
I wanted to show an excerpt from the forum post on the topic page.
<?php bbp_topic_excerpt ?> just doesnt output anything. Its completely blank
Ah, i used echo bbp_get_topic_excerpt( $topic_id, $length ); and it works fine.
Thank you 🙂
this does work like this: <?php bbp_topic_excerpt(); ?>