Mehrere Schleifen brechen Seitenleiste

Versuchen Sie, mithilfe von WP_query eine Reihe von Schleifen in die Seitenleiste zu setzen.

'page' , 'posts_per_page' => '-1' , 'post_parent' => '413')); if ( have_posts() ) : while ( $category_query_string->have_posts() ) : $category_query_string->the_post(); ?> <div class="FL-pest-cat"> <p class="FL-pest-cat-title">

<?php $postid = get_the_ID(); if ($postid == '654') { $curretnCat = '11';} elseif ($postid == '661') { $curretnCat = '12';} elseif ($postid == '662') { $curretnCat = '13';} elseif ($postid == '664') { $curretnCat = '15';} elseif ($postid == '665') { $curretnCat = '16';} elseif ($postid == '666') { $curretnCat = '17';} elseif ($postid == '668') { $curretnCat = '18';} elseif ($postid == '669') { $curretnCat = '19';} elseif ($postid == '670') { $curretnCat = '20';} elseif ($postid == '671') { $curretnCat = '21';} elseif ($postid == '673') { $curretnCat = '22';} elseif ($postid == '674') { $curretnCat = '23';} echo '
'; echo '
    '; $query_string = new WP_Query(array( 'post_type' => 'Pests', 'posts_per_page' => '-1' , 'cat' => $curretnCat )); if ( have_posts() ) : while ( $query_string->have_posts() ) : $query_string->the_post(); ?>
  • <p class="FL-pest-indv-title"><a href="https://wordpress.stackexchange.com/questions/34629/multiple-loops-breaking-side-bar/">

Es endet nur mit dem Brechen der Seite, funktioniert aber als Seitenvorlage.

Solutions Collecting From Web of "Mehrere Schleifen brechen Seitenleiste"

Da die Seitenleiste innerhalb der Schleife eingesetzt wurde, wurde die

 if ( have_posts() ) : 

war es, was dazu führte, dass es kaputt ging. Hier ist die Lösung:

  
< ?php $category_query_string = new WP_Query(array( 'post_type' => 'page' , 'posts_per_page' => '-1' , 'post_parent' => '413')); while ( $category_query_string->have_posts() ) : $category_query_string->the_post(); ?>
class="FL-pest-cat">

class="FL-pest-cat-title"> < ?php the_title(); ?>

< ?php $postid = get_the_ID(); if ($postid == '654') { $curretnCat = '11';} elseif ($postid == '661') { $curretnCat = '12';} elseif ($postid == '662') { $curretnCat = '13';} elseif ($postid == '664') { $curretnCat = '15';} elseif ($postid == '665') { $curretnCat = '16';} elseif ($postid == '666') { $curretnCat = '17';} elseif ($postid == '668') { $curretnCat = '18';} elseif ($postid == '669') { $curretnCat = '19';} elseif ($postid == '670') { $curretnCat = '20';} elseif ($postid == '671') { $curretnCat = '21';} elseif ($postid == '673') { $curretnCat = '22';} elseif ($postid == '674') { $curretnCat = '23';} echo '
'; $query_string = new WP_Query(array( 'post_type' => 'Pests', 'posts_per_page' => '-1' , 'cat' => $curretnCat )); while ( $query_string->have_posts() ) : $query_string->the_post(); ?>

class="FL-pest-indv-title"> < ?php the_title(); ?>

< ?php endwhile; ?> < ?php wp_reset_query(); ?>
< ?php endwhile; ?> < ?php wp_reset_query(); ?>