douqiu0351 2014-10-09 14:59
浏览 13

密码保护获取帖子的页面模板?

I've built a template which gets posts from a category and have added this in as i want it to be password protected. It doesn't seem to work and i don't know why.

Is anyone kind enough to help me out?

<?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();
 }

 ?>
  • 写回答

2条回答 默认 最新

  • douba1498 2014-10-10 13:52
    关注
    `<?php
    /*
    Template Name: Privileged Customers Template
    */
    
    get_header();
    ?>
    <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td><img src="../../../images/blank_middle/blank_middle_01.jpg" width="57" height="20"></td>
    <td><img src="../../../images/blank_middle/blank_middle_02.jpg" width="886" height="20"></td>
    <td><img src="../../../images/blank_middle/blank_middle_03.jpg" width="57" height="20"></td>
     </tr>
     <tr>
    <td background="../../../images/blank_middle/blank_middle_04.jpg"><img src="../../../images/spacer.gif" width="57" height="416" /></td>
    <td valign="top" background="../../../images/blank_middle/blank_middle_05.jpg"><table width="886"   border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="../../../images/spacer.gif" width="30" height="1" /></td>
          <td><img src="../../../images/spacer.gif" width="826" height="1" /></td>
          <td><img src="../../../images/spacer.gif" width="30" height="1" /></td>
        </tr>
        <tr>
          <td><img src="../../../images/spacer.gif" width="30" height="10" /></td>
          <td align="left">
          <div id="content" class="narrowcolumn" role="main">
     <h2><?php the_title();?></h2>
     <?php do_action('posts_logout_link'); ?>
     <?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();
    }
    
    ?>
    
    
    
      </div>
          </td>
          <td><img src="../../../images/spacer.gif" width="30" height="10" /></td>
        </tr>
      </table></td>
    <td background="../../../images/blank_middle/blank_middle_06.jpg"><img    src="../../../images/spacer.gif" width="57" height="416" /></td>
    

    `

    评论

报告相同问题?

悬赏问题

  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表