admin管理员组文章数量:1393090
How to query post without specific categories for example "two"and "three"
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => 3);
$category_home = new WP_Query($args);
if($wp_query->have_posts()) :
while($wp_query->have_posts()) :
$wp_query->the_post(); ?>
How to query post without specific categories for example "two"and "three"
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => 3);
$category_home = new WP_Query($args);
if($wp_query->have_posts()) :
while($wp_query->have_posts()) :
$wp_query->the_post(); ?>
Share
Improve this question
asked Feb 11, 2020 at 22:57
nabukenabuke
231 silver badge3 bronze badges
3
- 1 have you checked developer.wordpress/reference/classes/wp_query/… ? you might need to use the category ids for this. – Michael Commented Feb 11, 2020 at 23:02
- Are you trying to print the posts without including the category in the displayed HTML? Or trying to query posts without using categories? – Pixelsmith Commented Feb 12, 2020 at 1:14
- @Pixelsmith trying to quert post without using categories – nabuke Commented Feb 12, 2020 at 1:18
1 Answer
Reset to default 0I solved it like this array:
<?php
$args = array(
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'showposts' => '3',
'cat' => '-1,-2,-3',
);
本文标签: Query prints posts without specific categories
版权声明:本文标题:Query prints posts without specific categories 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744756825a2623512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论