我试图将我的循环限制为一个类别。这是循环:
<?php
$counter = 1; //start counter
$grids = 3; //Grids per row
global $query_string; //Need this to make pagination work
/*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
query_posts($query_string . \'&caller_get_posts=1&posts_per_page=9&category=5\');
if(have_posts()) : while(have_posts()) : the_post();
?>
<?php
//Show the left hand side column
if($counter == 1) :
?>
<div class="four columns">
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(\'home-thumb\'); ?></a>
</div>
<h3 style="text-align:center;"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</div>
<?php
//Show the middle column
elseif($counter == $grids) :
?>
<div class="four columns">
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(\'home-thumb\'); ?></a>
</div>
<h3 style="text-align:center;"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</div>
<?php
//Show the right hand side column
elseif($counter == $grids) :
?>
<div class="four columns">
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(\'home-thumb\'); ?></a>
</div>
<h3 style="text-align:center;"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
<p><?php the_excerpt(); ?></p>
</div>
<div class="clear"></div>
<?php
endif;
?>
<?php
endwhile;
//Pagination can go here if you want it.
endif;
?>
这是页面温度。
<?php
/*
Template Name: Web Design
*/
get_header(); ?>
<hr>
<div id="content" class="twelve columns">
<?php get_template_part(\'loop\', \'web\'); ?>
</div>
<?php get_footer(); ?>
它不起作用。请帮忙。谢谢