2013-03-19 20 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');?> 
相关问题