I have this code that should return all the posts that related to the taxonomy id, but it returns the last 5 posts.
<?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 is not working here, Any help to get all the posts.
Thanks
Try testing the simplest way possible:
<?php
$leaderships = new WP_Query(array(
'post_type' => 'leadership',
'posts_per_page' => -1
));
?>
If it returns all posts from "leadership" custom post type, then narrow it with 'tax_query' and check if You have more than 5 entries of custom post type "leadership" that are in custom taxonomy named "leadership-committee" in its created child (category/tag like) with id of 13.
Beside that, all looks ok in query.
感谢每个人的帮助,我发现问题出在我的主题管理区域,该区域将帖子限制为5个,现在已修复。
Here is the answer of the above question...
$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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.