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

  1. Override the ‘content-single-topic-lead.php‘ template.
  2. Find the line with the function call bbp_topic_post_date();
  3. 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

  1. Override the ‘loop-single-reply.php‘ template.
  2. Find the line with the function call bbp_reply_post_date();
  3. 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.

Please, take a few seconds and rate this answer
Rating: 2.7/5. From 5 votes. Votes Distribution.
Please wait...

Question answered by

Milan Petrovic

Programmer since the age of 12 and now WordPress developer with more than 8 years of WordPress experience, author of more than 100 plugins and more than 20 themes.

Grammerly - The World's Best Grammar Checker

The Comments

2 thoughts on “How to show topic/reply time since published instead published date?”

  1. Chris says:

    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?

    No votes yet.
    Please wait...
    1. This is one of the things that can’t be done via the hook, because template doesn’t have specific hook for it.

      No votes yet.
      Please wait...

Leave a Reply

Your email address will not be published. Required fields are marked *

Namecheap - Your dream domain awaits