【问题标题】:WordPress Custom Post Type Infinite LoopWordPress 自定义帖子类型无限循环
【发布时间】: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


【解决方案1】:

你不能在 webb 中做一个无限循环,它只是加载到浏览器崩溃或停止程序

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多