密码保护模板,安全内容不显示密码是否正确

时间:2015-09-01 作者:nirmal

下面是我的代码。现在的问题是,它完美地询问了安全页面的密码。

但即使我添加了正确的密码。我仍在寻呼询问密码。

下面是我的代码。

<?php
/**
 * Template Name: Page
 *
 */
global $post; 
if ( ! post_password_required( $post ) ) {
get_header();

?>
<div id="Content">
    <div class="content_wrapper clearfix">
secured content here

</div>
</div>
<?php 

get_footer(); 
}else{
    // we will show password form here
    echo get_the_password_form();
}

1 个回复
最合适的回答,由SO网友:nirmal 整理而成

我根据“TheDeadMedic”的建议解决了这个问题。

下面是代码。正如他所说,他在发帖时补充道。我在标题后添加了它。

<?php
/**
 * Template Name: Page
 *
 */
global $post; 
if ( ! post_password_required( $post ) ) {
get_header();
while ( have_posts() ) { the_post(); }
?>
<div id="Content">
    <div class="content_wrapper clearfix">
secured content here

</div>
</div>
<?php 

get_footer(); 
}else{
    // we will show password form here
    echo get_the_password_form();
}

相关推荐

是否有必要清理wp_set_password用户输入?

我正在尝试向WP注册表添加密码表单。请参见下面的代码。我想知道是否需要清理这个特定的用户输入?(如果是,怎么做?)如果我理解正确,WP为某些东西内置了净化功能,密码可能就是其中之一。对吗?WP会在将其添加到数据库之前自动对其进行清理吗?add_action( \'register_new_user\', \'registration_change_pass\', 10, 99 ); function registration_change_pass( $user_id ) { &