Skip to:
Content
Pages
Categories
Search
Top
Bottom

Showing Replies To Posts On Home Page – – Synced Posts w/ Forum Topics – –

  • @justin-mason

    Member

    Hello,

    On my current homepage, I was displaying 3 comments at a time per blog post by using the following code :

    <?php

    $number=3; // number of recent comments desired

    $post_id = get_the_ID();

    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->comments WHERE comment_post_ID=$post_id AND comment_approved = ‘1’ ORDER BY comment_date_gmt DESC LIMIT $number”);

    ?>

    <?php if ($comments) :

    foreach ( (array) $comments as $comment) :

    echo ‘<div class=”ddcomment”>’;

    echo ‘<p>‘, comment_author() . ‘ says:</p>’;

    echo comment_text();

    echo ‘</div>’;

    endforeach;

    endif; ?>

    This code works perfectly in displaying my comments on the homepage. However, I’ve decided to add bbpress forums and sync my topics with my posts.

    If you add a reply now to a post, it is not reflected on the homepage comments (since it is a reply from bbpress, not a wp comment). I am trying modify this code so I can pull the correct replies for that particular Post or Topic ID, since it is now synced together.

    The site is currently located at http://www.propaintball.tv

    Is there a specific database query I can use to replace my $comments variable with the topic replies? Thank You for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • @justin-mason

    Member

    The database query I think should be

    $comments = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent=$post_id AND post_type = ‘reply’ ORDER BY post_date_gmt DESC LIMIT $number”);

    (querying wp_posts, matching post_parent with post id, and post_types reploy)

    But how can I echo this $comments variable correctly?

    Its not working…

    Please help me, I know I’m on the right track but need assistance from an expert.

    @justin-mason

    Member

    Can anyone lend a hand here? Would really appreciate it.

    @anointed

    Participant

    Not ignoring you, just don’t know how to do this. Not even sure you you managed to sync replies to posts..

    @justin-mason

    Member

    Try the bbpress-post-topics plugin. :)

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar