我正在通过短代码向WordPress的帖子/页面显示帖子,并希望显示无限的帖子列表,但它只显示10个帖子.
这是我的代码; 请指导我的查询有什么问题.
$args = array( 'post_type' => 'post', 'cat' => '2', 'meta_key' => 'issue_of_article', 'meta_value' => $issue, 'posts_per_page' => -1, 'orderby' => 'artcle_category', 'order' => 'ASC');
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
$loop->the_post();
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
endwhile;
}
Run Code Online (Sandbox Code Playgroud)
小智 12
只需在你的论证中添加它
'posts_per_page' => -1
Run Code Online (Sandbox Code Playgroud)
那你就完成了
还有一件事:您可以将默认设置从管理员更改为10以外的其他设置.转到WordPress管理员 - 设置 - 阅读.有一个选项,如"博客页面最多显示".在那里输入您想要的帖子数量作为默认值.