我使用自定义帖子类型UI Wordpress插件创建自定义帖子类型(场地)和自定义分类(场地类型) 。然后,我创建了大约65个Venue项目,并尝试使用以下循环脚本在页面上显示它们。不幸的是,每个场地类型的结果仅限于10个场地项目。有什么想法吗?
<?php
$args = array(
'orderby' => 'name',
'hide_empty' => true,
'taxonomy' => 'venue_type'
);
$categories = get_categories($args);
foreach( $categories as $category ) {
echo '<div class="ui-accordion-header">';
echo "<div>";
echo "<h3>" . $category->name . "</h3>";
echo "<p>" . $category->description . "</p>";
echo "</div>";
echo "</div>";
$newargs = array(
'post_type' => 'venue',
'tax_query' => array(
array(
'taxonomy' => 'venue_type',
'field' => 'slug',
'terms' => $category->slug
)
)
);
echo '<div>';
echo "<div>";
echo '<ul class="cs-grid cs-style">';
query_posts( $newargs );
if (have_posts()) :
while (have_posts()) : the_post();
echo "<li>";
echo "<figure>";
the_post_thumbnail();
echo "<figcaption>";
echo "<h3>";
the_title();
echo "</h3>";
echo "<span>";
the_field('location');
echo " "; echo "|"; echo " ";
echo 'Capacity'; echo " "; the_field('capacity');
echo "</span>";
echo "</figcaption>";
echo "</figure>";
echo "</li>";
endwhile;
endif;
echo "</ul>";
echo "</div>";
echo "</div>";
}
?>
答案 0 :(得分:0)
这可能是因为您将其设置为仅显示一页10个项目。添加'posts_per_page' => -1,
应该有效。
$newargs = array(
'post_type' => 'venue',
'tax_query' => array(
array(
'taxonomy' => 'venue_type',
'field' => 'slug',
'terms' => $category->slug
)
会变成
$newargs = array(
'post_type' => 'venue',
'tax_query' => array(
array(
'taxonomy' => 'venue_type',
'field' => 'slug',
'terms' => $category->slug,
'posts_per_page' => -1
)
答案 1 :(得分:0)
查看'设置 - &gt;阅读Wordpress管理页面中的页面。在那里,您可以配置每个列表页面应显示的帖子数量。
祝你好运!
/意志