两者the_content() 以及the_excerpt() 模板标签已经用于密码保护的帖子,通过post_password_required() 有条件的如果您需要在the_content()/the_excerpt(), 致电post_password_required() 直接有条件。
例如,如果您不希望在帖子受密码保护的情况下输出注释模板。您可以执行以下操作:
if ( ! post_password_required() && ( is_single() || ( is_page() && comments_open() ) ) ) {
comments_template( \'\', true );
}
或者,如果您根本不想在帖子受密码保护的情况下显示帖子,可以在循环中执行以下操作:
if ( post_password_required() ) {
return;
} else {
// Normal Loop Post output goes here
}