[英]Return all posts for a custom taxonomy id in wordpress
我有此代码应返回与分类法ID相关的所有帖子,但它返回最后5个帖子。
<?php
$leaderships = new WP_Query(array(
'post_type' => 'leadership',
'posts_per_page' => 11,
'tax_query' => array(
array(
'taxonomy' => 'leadership-committee',
'field' => 'id',
'terms' => 13,
),
),
));
?>
posts_per_page在这里不起作用,获取所有帖子的任何帮助。
谢谢
尝试测试最简单的方法:
<?php
$leaderships = new WP_Query(array(
'post_type' => 'leadership',
'posts_per_page' => -1
));
?>
如果它返回“ leadership”自定义帖子类型的所有帖子,则使用“ tax_query”将其缩小,并检查在其创建的自定义分类法中是否有5个以上的自定义帖子类型“ leadership”条目属于“ leadership-committee” ID为13的孩子(类别/标签之类)
除此之外,所有查询都可以。
感谢每个人的帮助,我发现问题出在我的主题管理区域,该区域将帖子限制为5个,现在已修复。
这是上述问题的答案...
$args = array('post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => 619,
),
),
);
$loop = new WP_Query($args);
if($loop->have_posts()) {
echo '<h2>'.$custom_term->name.'</h2>';
while($loop->have_posts()) : $loop->the_post();
echo '<a href="'.get_permalink().'">'.get_the_title().'</a>'."<br/>";
endwhile;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.