您应该查看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();
?>
Run Code Online (Sandbox Code Playgroud)
您可以将其他参数传递给WP_Query()以使其更适合您的需求。文档可以在这里找到。
| 归档时间: |
|
| 查看次数: |
11697 次 |
| 最近记录: |