2011-11-03 117 views

回答

1

你可以像这样打印第一只猫,然后是其他猫,然后是其他帖子。你需要做3个querys和使用wp_reset_query():

例如:

<? */ loop #1 with category ID 9 */ ?> 
<?php query_posts($query_string . '&cat=9'); ?> 
<?php if (have_posts()) while (have_posts()) : the_post(); ?> 
    <? the_title(); //just something to print out ?> 
<? endwhile; wp_reset_query(); // end loop #1 and reseting query ?> 

<? */ loop #2 with category ID 10 */ ?> 
<?php query_posts($query_string . '&cat=10'); ?> 
<?php if (have_posts()) while (have_posts()) : the_post(); ?> 
    <? the_title(); //just something to print out ?> 
<? endwhile; wp_reset_query(); // end loop #2 and reseting query ?> 

结果将是后对猫9的列表,然后后对猫清单10.如果那么您需要打印其余类别的其他帖子。再次做同样的事情,但排除查询中的那些猫。 That's puting一个“ - ”在猫参数,像这样:

<? */ loop #3 excluded categories 9 and 10 */ ?> 
<?php query_posts($query_string . '&cat=-10,-9'); ?> 
<?php if (have_posts()) while (have_posts()) : the_post(); ?> 
    <? the_title(); //just something to print out ?> 
<? endwhile; wp_reset_query(); // end loop #3 and reseting query ?> 

That's的方式,可能会做同样的事情很多,但是这很容易理解。

希望有所帮助。

+0

我想通过检查法典。不管怎么说,多谢拉。 – Kenshi