2013-03-19 19 views

回答

4

您應該查看WP_Query()以輸出自定義帖子類型。下面的代碼獲取所有類型爲「custom_post_type」的自定義帖子,將它們放入一個名爲$ loop的變量中,並遍歷它,輸出其中包含的每個帖子的標題。

<?php 
// Get the 'Profiles' post type 
$args = array(
    'post_type' => 'custom_post_type', 
); 
$loop = new WP_Query($args); 

while($loop->have_posts()): $loop->the_post(); 

the_title(); 

endwhile; 
wp_reset_query(); 
?> 

還有其他的參數可以傳遞給WP_Query()以使它更適合您的需求。文檔可以在here找到。

0

前右「的循環」,你可能也只是使用:

<?php query_posts('post_type=your_custom_post_type');?> 
相關問題