【发布时间】:2014-10-09 14:59:15
【问题描述】:
我已经构建了一个模板,该模板从一个类别中获取帖子并添加了它,因为我希望它受到密码保护。它似乎不起作用,我不知道为什么。
有好心人帮帮我吗?
<?php
if ( ! post_password_required( $post ) ) {
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('cat=495' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div <?php post_class() ?>>
<h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<div class="entry">
<?php the_content() ?>
</div>
<br>
</div>
<?php endwhile; ?>
}else{
// we will show password form here
echo get_the_password_form();
}
?>
【问题讨论】:
-
愚蠢的问题,但你真的用密码保护了帖子本身吗?
-
不,我没有对帖子进行密码保护,因为这会非常耗时。我真的希望该页面被锁定,然后当您输入密码时,它会显示该类别的帖子。目前还没有在网上找到任何解决方案...
-
不,我的意思是您是否在运行此模板的“页面”上添加了密码?这个页面正在拉不同的帖子......但是页面本身需要密码......
-
哦,是的,对不起,我有。测试页面时,我收到此错误消息“ Parse error: syntax error, unexpected $end in /home/fhlinux221/j/jenningsrugs.co.uk/user/htdocs/pages/wp-content/themes/default/priviledged-customers .php 在第 65 行"
-
好吧,看来这个故事还有更多内容!上面的代码不是 65 行,所以请将代码发布到“privileged-customers.php”页面,我会找到你的错误。