When viewing topics or replies, in the header, you can see the exact date and time when the topic or reply is published.
But, with some minor changes, you can show the time passed since the publish date instead. This is similar to freshness that bbPress shows in the topics and forums lists. To make this change, you need to modify the bbPress templates for displaying single topic and reply. It is not recommended to directly modify bbPress templates, instead, override the templates through your theme by following this tutorial.
The method displayed here affects topics and replies displayed on the single topic or single reply pages.
Lead Topic Template
- Override the ‘content-single-topic-lead.php‘ template.
- Find the line with the function call bbp_topic_post_date();
- Replace that function call with bbp_time_since(get_the_time(‘U’, bbp_get_topic_id()));
So, the line in the original template looks like:
<span class="bbp-topic-post-date"><?php bbp_topic_post_date(); ?></span>
And in the override file it should be:
<span class="bbp-topic-post-date"><?php bbp_time_since(get_the_time('U', bbp_get_topic_id())); ?></span>
Single Reply Template
- Override the ‘loop-single-reply.php‘ template.
- Find the line with the function call bbp_reply_post_date();
- Replace that function call with bbp_time_since(get_the_time(‘U’, bbp_get_reply_id()));
So, the line in the original template looks like:
<span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span>
And in the override file it should be:
<span class="bbp-reply-post-date"><?php bbp_time_since(get_the_time('U', bbp_get_reply_id())); ?></span>
Notice
By default, bbPress uses Reply template to show the lead topic in the single topic page. Lead Topic Template is used only when the lead topic is active.
This is great!
Wouldn’t it be better to write a hook in the themes functions.php so it doesn’t get wiped when bbpress updates?
This is one of the things that can’t be done via the hook, because template doesn’t have specific hook for it.