Skip to main content
2 of 2
removed extra closing div
eteich
  • 756
  • 5
  • 9

Multiple loops breaking side bar

Trying to put a bunch of loops in the side bar using WP_query.

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

<div <?php
     $catspacetitle = get_the_title();
     $cattitle = str_replace(" ", "-", $catspacetitle);
     
     echo 'id="',$cattitle,'"' 
     ?> class="FL-pest-cat">
<p <?php
     $pcatspacetitle = get_the_title();
     $pcattitle = str_replace(" ", "-", $pcatspacetitle);
     
     echo 'id="',$pcattitle,'-title"' 
     ?>class="FL-pest-cat-title"><a href="#"><strong>
  <?php the_title(); ?>
  </strong></a></p>


<?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 '<div id="pests-cat-',$curretnCat,'"class="FL-pest-indv">';
  echo '<ul>';

$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(); ?>
    <li>
    <p <?php
     $pestspacetitle = get_the_title();
     $pesttitlesearch = array(' ', '(', ')', '.');
     $pesttitlereplace = array('-', '', '','');
     $pesttitle = str_replace($pesttitlesearch, $pesttitlereplace, $pestspacetitle);
     
     echo 'id="',$pesttitle,'"' 
     ?>class="FL-pest-indv-title"><a href="<?php the_permalink(); ?>"><strong>

  <?php the_title(); ?>
  </strong></a></p>
</li>
<?php endwhile; endif; ?>
<?php   wp_reset_query(); ?>
</ul>
</div>  </div>
<?php endwhile; endif; ?>
<?php   wp_reset_query(); ?>
  </div>

It just ends up breaking the page, but works on it's own as a page template.

eteich
  • 756
  • 5
  • 9