bbPress: "Topic Starter" Badge on Replies
Adds a small "Topic starter" badge under the author's name on replies written by the person who opened the topic, making long threads easier to follow.
Opens WPIDE on
Code
if ( ! function_exists( 'bbp_get_reply_author_id' ) ) {
return;
}
add_action( 'bbp_theme_after_reply_author_details', function () {
$reply_id = (int) bbp_get_reply_id();
$topic_id = (int) bbp_get_reply_topic_id( $reply_id );
$author_id = (int) bbp_get_reply_author_id( $reply_id );
// The opening post itself is the topic, so only mark later replies.
if ( ! $author_id || $reply_id === $topic_id || $author_id !== (int) bbp_get_topic_author_id( $topic_id ) ) {
return;
}
echo '<span class="wpide-bbp-starter" style="display:inline-block;margin-top:.3em;padding:0 .5em;border-radius:999px;border:1px solid currentColor;font-size:.75em">Topic starter</span>';
} );
Notes
Style the badge with the .wpide-bbp-starter class.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.