代码片段:在 bbPress 论坛帖子里添加“楼主”标识

作者:虫洞原文发布于薇晓朵论坛,如有侵权请联系我删除。

在您的主题(推荐用子主题)里的function.php里添加以下代码:

//添加楼主和非楼主角色
function bbp_post_starter( $args = '' ) {
	$topic_author = bbp_get_topic_author_id();
	$reply_author = bbp_get_reply_author_id( $reply_id );
	if ( bbp_is_single_user_replies() ) {
	}
	elseif ( $reply_author === $topic_author ) {
		?>
        <span class="post-starter-bq"> 楼主</span>
        <?php
	}
}
add_filter('bbp_theme_after_reply_author_details', 'bbp_post_starter');

在主题里的style.css里添加以下代码:

.post-starter-bq{
    background-color: #588eee;/*可以修改*/
    border-radius:3px;
    color: #fff;
}

效果: