Showing Replies To Posts On Home Page – – Synced Posts w/ Forum Topics – -
-
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!
You must be logged in to reply to this topic.