Info
- 7 posts
- 4 voices
- Started 2 years ago by blah
- Latest reply from Tom(dB)
- This topic is not resolved
show number of comments?
-
- Posted 2 years ago #
I'd like to show the number of comments that a topic has. How would I go about doing this?
Thanks in advance.
-
- Posted 2 years ago #
crackpixels,
In bbPress Comments are generally called Posts.
I think the Posts column is set up by default.
In the Latest Discussions table, look for this cell: <th><?php _e('Posts'); ?></th>, which is the title of the column, and this:<td class="num"><?php topic_posts(); ?></td>, which is the content of the comuns, displaying the number of Posts (Comments).
-
- Posted 2 years ago #
One quick note: posts include the "first post", i.e. the original topic. If you want to only show comments on that first post, you have to subtract one from the post count.
-
- Posted 2 years ago #
Thanks you guys.
johnhiler - How would I subtract one from the post count?
-
- Posted 2 years ago #
Something like this:
<div class="commentcount"><?php $commentcount = $topic->topic_posts -1; echo ($commentcount) ?> <img alt="number of comments" src="/images/sticky-bubble.gif" /></div>
-
- Posted 2 years ago #
Is there a way I can work that into this: <?php topic_posts(); ?>
-
- Posted 2 years ago #
You'd replace the
topic_posts();with the code that johnhiler wrote.Is it worth running through that calculation for every listed post though? People on your forum would soon become familiar with Number of Posts rather than Replies to Post statistics.
-
You must log in to post.