Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WordPress多重循环混淆_Wordpress - Fatal编程技术网

WordPress多重循环混淆

WordPress多重循环混淆,wordpress,Wordpress,我想在我的WordPress博客上显示多个循环。这些类别如下: 头条新闻(每页1篇) 小故事(每页1篇) 正常(每页1个) 快速填充(每页2个) 我有4个循环来显示这些。我试图显示每页的帖子数量,一旦它们被显示,就不再在另一页上显示,因为我不想显示重复的帖子 我的循环如下。我似乎得到了复制品,当我试图让他们删除复制品时,我倾向于在不知道如何删除的情况下删除所有东西 头条新闻-第一圈 <?php global $do_not_duplicate; $do

我想在我的WordPress博客上显示多个循环。这些类别如下:

  • 头条新闻(每页1篇)
  • 小故事(每页1篇)
  • 正常(每页1个)
  • 快速填充(每页2个)
我有4个循环来显示这些。我试图显示每页的帖子数量,一旦它们被显示,就不再在另一页上显示,因为我不想显示重复的帖子

我的循环如下。我似乎得到了复制品,当我试图让他们删除复制品时,我倾向于在不知道如何删除的情况下删除所有东西

头条新闻-第一圈

<?php 
        global $do_not_duplicate;
        $do_not_duplicate = array();

        $paged = max(1, get_query_var('paged'));
        $my_query = new WP_Query('category_name=top-story&posts_per_page=1&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php 
        $my_query = new WP_Query('category_name=small-story&posts_per_page=1&paged='.$paged);
        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; 
        ?>
        // content
<?php endwhile; ?>
<?php $my_query = new WP_Query('category_name=normal&posts_per_page=1&paged='.$paged);
while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php   
        $int = 0;
        $my_query = new WP_Query('category_name=quickfill&posts_per_page=2&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;       
        $do_not_duplicate[] = $post->ID; 
            if ($int==0) { ?>
                <hr class="seperator" />
                <div class="gr_bg_post">
                    <img src="<?php bloginfo('template_directory'); ?>/images/quickfill.png" />
            <?php } ?>
                <div class="fl">
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <?php the_content('<button type="button" class="read_more_green">Read More</button>'); ?>
                </div>
            <?php if ($int==1) { ?>
            </div>
        <?php } ?>
        <?php $int++; ?>
        <?php endwhile; ?>

//内容
小故事-第二圈

<?php 
        global $do_not_duplicate;
        $do_not_duplicate = array();

        $paged = max(1, get_query_var('paged'));
        $my_query = new WP_Query('category_name=top-story&posts_per_page=1&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php 
        $my_query = new WP_Query('category_name=small-story&posts_per_page=1&paged='.$paged);
        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; 
        ?>
        // content
<?php endwhile; ?>
<?php $my_query = new WP_Query('category_name=normal&posts_per_page=1&paged='.$paged);
while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php   
        $int = 0;
        $my_query = new WP_Query('category_name=quickfill&posts_per_page=2&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;       
        $do_not_duplicate[] = $post->ID; 
            if ($int==0) { ?>
                <hr class="seperator" />
                <div class="gr_bg_post">
                    <img src="<?php bloginfo('template_directory'); ?>/images/quickfill.png" />
            <?php } ?>
                <div class="fl">
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <?php the_content('<button type="button" class="read_more_green">Read More</button>'); ?>
                </div>
            <?php if ($int==1) { ?>
            </div>
        <?php } ?>
        <?php $int++; ?>
        <?php endwhile; ?>

//内容
正常帖子(注意:该类别实际上称为正常)——第三圈

<?php 
        global $do_not_duplicate;
        $do_not_duplicate = array();

        $paged = max(1, get_query_var('paged'));
        $my_query = new WP_Query('category_name=top-story&posts_per_page=1&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php 
        $my_query = new WP_Query('category_name=small-story&posts_per_page=1&paged='.$paged);
        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; 
        ?>
        // content
<?php endwhile; ?>
<?php $my_query = new WP_Query('category_name=normal&posts_per_page=1&paged='.$paged);
while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php   
        $int = 0;
        $my_query = new WP_Query('category_name=quickfill&posts_per_page=2&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;       
        $do_not_duplicate[] = $post->ID; 
            if ($int==0) { ?>
                <hr class="seperator" />
                <div class="gr_bg_post">
                    <img src="<?php bloginfo('template_directory'); ?>/images/quickfill.png" />
            <?php } ?>
                <div class="fl">
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <?php the_content('<button type="button" class="read_more_green">Read More</button>'); ?>
                </div>
            <?php if ($int==1) { ?>
            </div>
        <?php } ?>
        <?php $int++; ?>
        <?php endwhile; ?>

//内容
快速填充-第四个循环

<?php 
        global $do_not_duplicate;
        $do_not_duplicate = array();

        $paged = max(1, get_query_var('paged'));
        $my_query = new WP_Query('category_name=top-story&posts_per_page=1&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php 
        $my_query = new WP_Query('category_name=small-story&posts_per_page=1&paged='.$paged);
        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; 
        ?>
        // content
<?php endwhile; ?>
<?php $my_query = new WP_Query('category_name=normal&posts_per_page=1&paged='.$paged);
while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;
        $do_not_duplicate[] = $post->ID; ?>
        // content
<?php endwhile; ?>
<?php   
        $int = 0;
        $my_query = new WP_Query('category_name=quickfill&posts_per_page=2&paged='.$paged);

        while ($my_query->have_posts()) : $my_query->the_post();
        if (in_array($post->ID, $do_not_duplicate)) continue;       
        $do_not_duplicate[] = $post->ID; 
            if ($int==0) { ?>
                <hr class="seperator" />
                <div class="gr_bg_post">
                    <img src="<?php bloginfo('template_directory'); ?>/images/quickfill.png" />
            <?php } ?>
                <div class="fl">
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <?php the_content('<button type="button" class="read_more_green">Read More</button>'); ?>
                </div>
            <?php if ($int==1) { ?>
            </div>
        <?php } ?>
        <?php $int++; ?>
        <?php endwhile; ?>


/图像/quickfill.png“/>
上次查询中缺少查询变量
$my\u query

$my_query = new WP_Query(array('post_not_in' => $do_not_duplicate));

if ($my_query->have_posts()) : while ($my_query>have_posts()) : $my_query>the_post();
    // content
endwhile; endif;

尝试重置查询,这可能是问题所在--重置查询后仍然存在相同的问题。