2011-11-03 50 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

相關問題