为 bbPress 论坛帖子添加 “楼主” 标识

类似其他的论坛,帖子的发布者会带有 “楼主” 标识。

转载自薇晓朵技术论坛

将下面的代码片段添加到已激活主题的 functions.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');
文章没看懂?代码不会用?需要帮助您可以去论坛提问自助服务台

作者Geticer

WordPress的忠实用户,喜欢讲述与BuddyPress和bbPress等有关的故事。 同时也是一位Minecraft玩家……