How to rewrite post dates for certain categories (narrative project roleplay)

Oooo, sounds fun! There likely isn’t any existing solutions for this, and I can’t really imagine a legitimate reason to create one that would actually change the actual timestamp. What you can do instead is create a custom Theme Component that would insert a fake timestamp per post.

You can add a generic [wrap] bbcode, which will let you use any arbitrary [wrap=] bbcode in the posts you want to change.

Set something up like [wrap=timechange time='Apr 1'][/wrap] and you’ll get <span class="d-wrap" data-time="Apr 1" data-wrap="timechange"></span> in the post itself. Then you can use decorateCookedElement() to search for [data-wrap="timechange"] in each post to decide if it the timestamp should be changed.

I don’t think there’s a plugin outlet at the timestamp, but you can always just insert a new element in the post-date anchor element and use some CSS to hide the old.

Here’s what the current post-date looks like.

<div class="post-info post-date">
  <a class="widget-link post-date" href="..." title="Post date">
    <span title="..." data-time="..." data-format="tiny" class="relative-date">...</span>
  </a>
</div>

You’ll want to probably target .post-info a.post-date and add a new element there as a span or something of the like. Some CSS .post-info a.post-date span:first-child { display: none; } will hide the real timestamp. Targeting the anchor tag and preserving it will let your users be able to continue to use it normally (it has share functionality).

Connecting it to the decorateCookedElement(), the function gives you the root element of the cooked post, so you can do a quick search up the DOM from there with element.closest() and .querySelector() to reach the correct .post-info.

Using bbcode would let you (and anyone else) change the the visual of any post, regardless of category. You can also limit where it actually gets displayed with some clever CSS. The body should have the class .category-* that will have the category name of the topic. So you can limit your CSS to those categories.