loop-topics.php:显示所有帖子,代码分为3部分:页面的头部,身体,脚。页面的身体由loop-single-topic.php控制
loop-single-topic.php:控制显示帖子的头部,参与人,帖子,最后发表等内容
form-topic.php: 创建一个新的话题,填写匿名者回复的信息和其个人信息 ,其个人信息由form_anonymous.php控制
form_anonymous.php: 填写匿名回复者的个人信息
loop-replys.php:显示帖子下的所有回复
loop-single-reply.php :显示回复的所有内容
/public_html/wp-content/plugins/bbpress/includes/users/template.php 获取匿名者填写的名字,邮箱,网页
修改“wp-content/plugins/bbpress/templates/default/loop-topics.php”
修改前的代码如下:
<?php
/**
* Topics Loop
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
do_action( 'bbp_template_before_topics_loop' ); ?>
<ul id="bbp-forum-<?php bbp_forum_id(); ?>" class="bbp-topics">
<li class="bbp-header">
<ul class="forum-titles">
<li class="bbp-topic-title"><?php esc_html_e( 'Topic', 'bbpress' ); ?></li>
<li class="bbp-topic-voice-count"><?php esc_html_e( 'Voices', 'bbpress' ); ?></li>
<li class="bbp-topic-reply-count"><?php bbp_show_lead_topic()
? esc_html_e( 'Replies', 'bbpress' )
: esc_html_e( 'Posts', 'bbpress' );
?></li>
<li class="bbp-topic-freshness"><?php esc_html_e( 'Last Post', 'bbpress' ); ?></li>
</ul>
</li>
<li class="bbp-body">
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
</li>
<li class="bbp-footer">
<div class="tr">
<p>
<span class="td colspan<?php echo ( bbp_is_user_home() && ( bbp_is_favorites() || bbp_is_subscriptions() ) ) ? '5' : '4'; ?>"> </span>
</p>
</div><!-- .tr -->
</li>
</ul><!-- #bbp-forum-<?php bbp_forum_id(); ?> -->
<?php do_action( 'bbp_template_after_topics_loop' );
bbp-header是显示这个
bbp-body是显示这个:
/public_html/wp-content/plugins/bbpress/templates/default/bbpress/loop-single-topic.php
整个代码就四个部分,主题的头部,参与人,帖子,最后发表
<?php
/**
* Topics Loop - Single
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
?>
<ul id="bbp-topic-<?php bbp_topic_id(); ?>" <?php bbp_topic_class(); ?>>
<li class="bbp-topic-title">
<?php if ( bbp_is_user_home() ) : ?>
<?php if ( bbp_is_favorites() ) : ?>
<span class="bbp-row-actions">
<?php do_action( 'bbp_theme_before_topic_favorites_action' ); ?>
<?php bbp_topic_favorite_link( array( 'before' => '', 'favorite' => '+', 'favorited' => '×' ) ); ?>
<?php do_action( 'bbp_theme_after_topic_favorites_action' ); ?>
</span>
<?php elseif ( bbp_is_subscriptions() ) : ?>
<span class="bbp-row-actions">
<?php do_action( 'bbp_theme_before_topic_subscription_action' ); ?>
<?php bbp_topic_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '×' ) ); ?>
<?php do_action( 'bbp_theme_after_topic_subscription_action' ); ?>
</span>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'bbp_theme_before_topic_title' ); ?>
<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>"><?php bbp_topic_title(); ?></a>
<?php do_action( 'bbp_theme_after_topic_title' ); ?>
<?php bbp_topic_pagination(); ?>
<?php do_action( 'bbp_theme_before_topic_meta' ); ?>
<p class="bbp-topic-meta">
<?php do_action( 'bbp_theme_before_topic_started_by' ); ?>
<span class="bbp-topic-started-by"><?php printf( esc_html__( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span>
<?php do_action( 'bbp_theme_after_topic_started_by' ); ?>
<?php if ( ! bbp_is_single_forum() || ( bbp_get_topic_forum_id() !== bbp_get_forum_id() ) ) : ?>
<?php do_action( 'bbp_theme_before_topic_started_in' ); ?>
<span class="bbp-topic-started-in"><?php printf( esc_html__( 'in: %1$s', 'bbpress' ), '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>' ); ?></span>
<?php do_action( 'bbp_theme_after_topic_started_in' ); ?>
<?php endif; ?>
</p>
<?php do_action( 'bbp_theme_after_topic_meta' ); ?>
<?php bbp_topic_row_actions(); ?>
</li>
<li class="bbp-topic-voice-count"><?php bbp_topic_voice_count(); ?></li>
<li class="bbp-topic-reply-count"><?php bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count(); ?></li>
<li class="bbp-topic-freshness">
<?php do_action( 'bbp_theme_before_topic_freshness_link' ); ?>
<?php bbp_topic_freshness_link(); ?>
<?php do_action( 'bbp_theme_after_topic_freshness_link' ); ?>
<p class="bbp-topic-meta">
<?php do_action( 'bbp_theme_before_topic_freshness_author' ); ?>
<span class="bbp-topic-freshness-author"><?php bbp_author_link( array( 'post_id' => bbp_get_topic_last_active_id(), 'size' => 14 ) ); ?></span>
<?php do_action( 'bbp_theme_after_topic_freshness_author' ); ?>
</p>
</li>
</ul><!-- #bbp-topic-<?php bbp_topic_id(); ?> -->
把"最后发表"删掉,检索"freshness",把相关代码删掉后代码如下:
/public_html/wp-content/plugins/bbpress/templates/default/bbpress/loop-topics.php
<?php
/**
* Topics Loop
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
do_action( 'bbp_template_before_topics_loop' ); ?>
<ul id="bbp-forum-<?php bbp_forum_id(); ?>" class="bbp-topics">
<li class="bbp-header">
<ul class="forum-titles">
<li class="bbp-topic-title"><?php esc_html_e( 'Topic', 'bbpress' ); ?></li>
<li class="bbp-topic-voice-count"><?php esc_html_e( 'Voices', 'bbpress' ); ?></li>
<li class="bbp-topic-reply-count"><?php bbp_show_lead_topic()
? esc_html_e( 'Replies', 'bbpress' )
: esc_html_e( 'Posts', 'bbpress' );
?></li>
</ul>
</li>
<li class="bbp-body">
<?php while ( bbp_topics() ) : bbp_the_topic(); ?>
<?php bbp_get_template_part( 'loop', 'single-topic' ); ?>
<?php endwhile; ?>
</li>
<li class="bbp-footer">
<div class="tr">
<p>
<span class="td colspan<?php echo ( bbp_is_user_home() && ( bbp_is_favorites() || bbp_is_subscriptions() ) ) ? '5' : '4'; ?>"> </span>
</p>
</div><!-- .tr -->
</li>
</ul><!-- #bbp-forum-<?php bbp_forum_id(); ?> -->
<?php do_action( 'bbp_template_after_topics_loop' );
/public_html/wp-content/plugins/bbpress/templates/default/bbpress/loop-single-topic.phpg
<?php
/**
* Topics Loop - Single
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
?>
<ul id="bbp-topic-<?php bbp_topic_id(); ?>" <?php bbp_topic_class(); ?>>
<li class="bbp-topic-title">
<?php if ( bbp_is_user_home() ) : ?>
<?php if ( bbp_is_favorites() ) : ?>
<span class="bbp-row-actions">
<?php do_action( 'bbp_theme_before_topic_favorites_action' ); ?>
<?php bbp_topic_favorite_link( array( 'before' => '', 'favorite' => '+', 'favorited' => '×' ) ); ?>
<?php do_action( 'bbp_theme_after_topic_favorites_action' ); ?>
</span>
<?php elseif ( bbp_is_subscriptions() ) : ?>
<span class="bbp-row-actions">
<?php do_action( 'bbp_theme_before_topic_subscription_action' ); ?>
<?php bbp_topic_subscription_link( array( 'before' => '', 'subscribe' => '+', 'unsubscribe' => '×' ) ); ?>
<?php do_action( 'bbp_theme_after_topic_subscription_action' ); ?>
</span>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'bbp_theme_before_topic_title' ); ?>
<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>"><?php bbp_topic_title(); ?></a>
<?php do_action( 'bbp_theme_after_topic_title' ); ?>
<?php bbp_topic_pagination(); ?>
<?php do_action( 'bbp_theme_before_topic_meta' ); ?>
<p class="bbp-topic-meta">
<?php do_action( 'bbp_theme_before_topic_started_by' ); ?>
<span class="bbp-topic-started-by"><?php printf( esc_html__( 'Started by: %1$s', 'bbpress' ), bbp_get_topic_author_link( array( 'size' => '14' ) ) ); ?></span>
<?php do_action( 'bbp_theme_after_topic_started_by' ); ?>
<?php if ( ! bbp_is_single_forum() || ( bbp_get_topic_forum_id() !== bbp_get_forum_id() ) ) : ?>
<?php do_action( 'bbp_theme_before_topic_started_in' ); ?>
<span class="bbp-topic-started-in"><?php printf( esc_html__( 'in: %1$s', 'bbpress' ), '<a href="' . bbp_get_forum_permalink( bbp_get_topic_forum_id() ) . '">' . bbp_get_forum_title( bbp_get_topic_forum_id() ) . '</a>' ); ?></span>
<?php do_action( 'bbp_theme_after_topic_started_in' ); ?>
<?php endif; ?>
</p>
<?php do_action( 'bbp_theme_after_topic_meta' ); ?>
<?php bbp_topic_row_actions(); ?>
</li>
<li class="bbp-topic-voice-count"><?php bbp_topic_voice_count(); ?></li>
<li class="bbp-topic-reply-count"><?php bbp_show_lead_topic() ? bbp_topic_reply_count() : bbp_topic_post_count(); ?></li>
</ul><!-- #bbp-topic-<?php bbp_topic_id(); ?> -->
效果如下:
关于do_action可以查看以下博客
https://www.cnblogs.com/sxwkt/archive/2013/04/28/3049203.html
以下代码控制标题下面的内容
修改WordPress地址后无法正常访问和登录后台的解决方法
删掉以下代码
可去掉以下内容
删掉以下代码
可去掉以下内容,说明form_anonymous跟以下内容有关
/public_html/wp-content/plugins/bbpress/includes/users/template.php
/public_html/wp-content/plugins/bbpress/includes/replies/template.php
必须改下面这个函数,否则是2个一样的值
bbp_form_topic_title在
/public_html/wp-content/plugins/bbpress/includes/topics/template.php