• I’ve been using Kinderlose to hide child category posts on category list pages, and I love its functionality – or I did until I started writing a sidebar for my site that uses get_posts to pull all the child categories of a completely different category and list them by category. The regex in Kinderlose ate the query for the sidebar and spit out something completely different.

    I need some help figuring out how to make the Kinderlose plugin rework the query for the main loop category, and ignore the sidebar query. Here’s the relevant code:

    Sidebar:

    <?php $parent_category = '26';
    	$categories = get_categories("orderby=id&hide_empty=1&child_of=$parent_category");
           	foreach($categories as $cate) : ?>
          		<h3><?php echo $cate->name; ?></h3>
                    <?php $cid = $cate->cat_ID; ?>
            	<ul>
               	<?php global $post;
                          $sidebarPosts = get_posts('numberposts=-1&category='.$cid);
    		      foreach($sidebarPosts as $post) : setup_postdata($post); ?>
               			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
               	      <?php endforeach; ?>
    
            	</ul>
      	<?php endforeach; ?>

    This is working great on every page except the category pages – when it appears on the ?cat=12 page, for example, it pulls the correct category headers for the sidebar, but every category post on the sidebar is from category 12.

    I can see why it works this way, why it only happens on category pages, and how it hooks into the get_posts query from the code; what I can’t figure out is, how do I limit it to grab the parent category for the page, and only affect queries based on that category ID, while ignoring my sidebar query?

    Thanks in advance,

    cSoul

The topic ‘[Plugin: Kinderlose] Problems with regex’ is closed to new replies.