admin管理员组文章数量:1130349
I want to show two latest posts of a taxonomy in a front_page.php template.
$args_article = array(
'post_type' => ['text'],
'post_status' => ['publish'],
'posts_per_page' => 2,
'tax_query' => [
[
'taxonomy' => 'article-type',
'field' => 'slug',
'terms' => 'articulo',
]
]
);
$query_article = new WP_Query( $args_article );
It returns all posts instead two latest.
It works without tax_query:
$args_article = array(
'post_type' => ['text'],
'post_status' => ['publish'],
'posts_per_page' => 2,
);
$query_article = new WP_Query( $args_article );
The loop is very simple (it is in Blade template syntax):
@while ($query_article->have_posts()) @php $query_article->the_post() @endphp
@include('partials.content-owl')
@endwhile
Entire code can be reached here.
And there is a provisional link with deployed site here. There are three similar loops in the front page.
How can I get just latest posts with a tax_query? Thanks!
I want to show two latest posts of a taxonomy in a front_page.php template.
$args_article = array(
'post_type' => ['text'],
'post_status' => ['publish'],
'posts_per_page' => 2,
'tax_query' => [
[
'taxonomy' => 'article-type',
'field' => 'slug',
'terms' => 'articulo',
]
]
);
$query_article = new WP_Query( $args_article );
It returns all posts instead two latest.
It works without tax_query:
$args_article = array(
'post_type' => ['text'],
'post_status' => ['publish'],
'posts_per_page' => 2,
);
$query_article = new WP_Query( $args_article );
The loop is very simple (it is in Blade template syntax):
@while ($query_article->have_posts()) @php $query_article->the_post() @endphp
@include('partials.content-owl')
@endwhile
Entire code can be reached here.
And there is a provisional link with deployed site here. There are three similar loops in the front page.
How can I get just latest posts with a tax_query? Thanks!
本文标签: wp querypostsperpage in a taxquery
版权声明:本文标题:wp query - posts_per_page in a tax_query 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749228758a2336124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论