我最近换了一个新主题,它似乎没有密码保护单个页面的功能。它仅在页面标题中显示“受保护”,但仍显示内容,而不提示输入密码。如何手动启用此功能?我试图将(if(post\\u password\\u required($post)){添加到自定义页面模板中,但没有成功。请在此帮助我使用正确的代码或其他解决方案。非常感谢!
<?php
// Template Name: Password Protected
get_header(); ?>
<!-- Margin -->
<div class="margin-2">
<div class="spacing-40"></div>
<!-- Single full Page Container-->
<div id="single-full">
<h1 class="entry-header"><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="spacing-20"></div>
<div class="entry wide-entry">
<?php
$my_postid = get_page( $page_id );//This is page id or post id
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters(\'the_content\', $content);
//$content = str_replace(\']]>\', \']]>\', $content);
echo $content;
?>
</div>
</div>
<!-- Single full Page Container-->
<!-- Margin -->
<div id="widget-container">
<?php
if ( !function_exists(\'dynamic_sidebar\')
|| !dynamic_sidebar(2) ) :
endif;
?>
</div>
<!-- Margin -->
<div class="clr"></div>
<div class="spacing-20"></div>
</div>
<div class="clr"></div>
<div class="spacing-40"></div>
</div>
<?php get_footer(); ?>