【发布时间】:2026-02-13 15:45:01
【问题描述】:
我使用 自定义帖子类型 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>";
}
?>
【问题讨论】:
标签: php wordpress wordpress-theming custom-post-type