Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I extract a topic/reply excerpt?


  • Michael
    Participant

    @michaelhpdx

    I haven’t been able to find a simple solution for building a topic/reply excerpt. I’ve checked for plugins and widgets, but can’t seem to find anything out there. I’m also using Advanced Post List plugin (http://wordpress.org/extend/plugins/advanced-post-list/) for building excerpts for other (non-bbpress) post types, and it does not seem to know how to to query the database correctly for the forum, topic and reply post types.

    What I’m trying to do is build a list of the most recent N posts to the forums (any/all), and list the member name, ideally their avatar, the topic name, and a ~100-200 word excerpt of the post.

    Certainly someone has done this before, and I’m just looking in all the wrong places. :-)

    Any ideas on how to do this? Many thanks in advance.

    Michael

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

  • mostafa ghanbari
    Participant

    @mostafaghanbari

    Hi Michael
    if i understood your question you simply want a list of topics in your forum like bbpress.org/forum! am i right?


    Michael
    Participant

    @michaelhpdx

    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


    Michael
    Participant

    @michaelhpdx

    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 1 year, 9 months ago by  Michael.

    Michael
    Participant

    @michaelhpdx

    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


    Michael
    Participant

    @michaelhpdx

    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


    mostafa ghanbari
    Participant

    @mostafaghanbari

    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! :D

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

You must be logged in to reply to this topic.