Php Wordpress显示10个帖子类型项目
我使用自定义帖子类型UIWordpress插件创建了自定义帖子类型(场馆)和自定义分类法(场馆类型)。然后,我创建了大约65个场馆项目,并尝试使用以下循环脚本在页面上显示它们。遗憾的是,每个场馆类型的结果仅限于10个场馆项目。你知道为什么吗Php Wordpress显示10个帖子类型项目,php,wordpress,wordpress-theming,custom-post-type,Php,Wordpress,Wordpress Theming,Custom Post Type,我使用自定义帖子类型UIWordpress插件创建了自定义帖子类型(场馆)和自定义分类法(场馆类型)。然后,我创建了大约65个场馆项目,并尝试使用以下循环脚本在页面上显示它们。遗憾的是,每个场馆类型的结果仅限于10个场馆项目。你知道为什么吗 <?php $args = array( 'orderby' => 'name', 'hide_empty' => true,
<?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>";
}
?>
这可能是因为您将其设置为每页仅显示10项。添加
“每页帖子”=>-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
)
查看Wordpress管理页面中的“设置->读取”页面。在那里,您可以配置每个列表页应显示多少帖子 这篇博文也很有用: 祝你好运
/Wille在“范围”中,你的答案没问题,但是如果上面的链接变暗,最好包含一个规范的例子。谢谢你的建议。我对在Stackoverflow写答案相当陌生。将在将来记住这一点!:)