将当前页面的查询与类别中所有帖子的查询分开
未测试示例:
<?php
/*
Template Name: xxxx
*/
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_header(); ?>
<?php if ( post_password_required() ) :
$args = array(
\'cat\' => 9,
\'numberposts\' => -1,
);
$posts = get_posts( $args );
foreach( $posts as $post ) : setup_postdata($post); ?>
<a href="<?php the_permalink(); ?>">
<h1 style="padding-top:0;margin-top:-5px" class="entry-title"><?php the_title(); ?></h1>
</a>
<div class="entry-content" style="padding:0"><?php the_content(); ?></div>
<div class="entry-meta">
<?php edit_post_link( __( \'Edit\', \'twentyeleven\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php get_footer(); ?>
<?php endwhile; ?>