我有一个带有自定义帖子类型食谱的worpress,我通过为某种食谱(比如鱼)做一个父帖子来订购帖子,然后我用食谱做帖子。
我想列出所有的帖子,但没有父页面。这并没有太大的问题,但我需要一个能处理这个问题的分页。有可能吗?
我试着列出所有的帖子,跳过父页面,但分页不起作用。
知道吗?
谢谢你提前提供的帮助。
这是代码
<?php
$args = array( 'post_type' => 'recipe', 'posts_per_page' => 3, 'paged' => $paged );
$loop = new WP_Query( $args );
while ($loop->have_posts()) : $loop->the_post();
$args = array(
'post_type' => 'recipe',
'post_parent' => $post->ID
);
$hasChildQ = new WP_Query( $args );
if( !$hasChildQ->have_posts() ){
get_template_part( 'content', 'recipe' );
}
endwhile; // end of the loop.
?>
但我希望它在主查询中完成,这样分页就可以使用它了
任何建议都很好。