【发布时间】:2016-12-20 17:05:29
【问题描述】:
我正在为我的自定义帖子类型存档页面使用 WP_query,并且查询似乎陷入了无限循环。
archive.php
<?php
$query = new WP_Query(array(
'post_type' => 'faqs',
'post_status' => 'publish',
'posts_per_page' => -1
));
while ($query->have_posts()) {
$query->the_post();
$faqs_loop = get_template_part('loop-faqs');
}
wp_reset_query();
?>
loop.php
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<div class="accordion-section">
<a class="accordion-section-title" href="#<?php the_id(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<div id="<?php the_id(); ?>" class="accordion-section-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
【问题讨论】:
-
是什么让你说存在无限循环?
标签: php wordpress infinite-loop custom-post-type