📖WordPress 备案时关闭评论

前言

在网站备案时由于是个人性质网站需要关闭网站评论,只需一行代码即可

代码

打开你主题目录下的 comments.php,添加以下内容

<?php
return;
/**
 * The template for displaying comments
 *
 * The area of the page that contains both current comments
 * and the comment form.
 *
 * @package WordPress
 * @subpackage RK blogger
 * @since Wbolt 1.0
 */

if ( post_password_required() ) {
	return;
}
?>
<section class="panel-inner sc-comments">
    <h3 class="sc-title">发表评论</h3>
	<?php
	// If comments are closed and there are comments, let's leave a little note, shall we?
	if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
		?>
        <p class="no-comments"><?php _e( 'Comments are closed.', 'wbolt' ); ?></p>
	<?php endif; ?>

只需在最开头添加一个 return; 即可

标签