2.1 – Multiple Queries
-
Hi,
I just upgraded to version 2.1 and using PHP 5.2.
In my sidebar, I query the categories with a custom SELECT statement. Under each category, lists of of posts are shown. (got the idea from this topic.
I’m using the <?php $temp_query = clone $wp_query; ?> method to save and reset the posts as discussed in the codex The Loop page.
However, the query doesn’t reset and I can’t use the original query after the sidebar.
<div id=”navcontainer”>
<ul id=”navlist”>
<?php $temp_query = clone $wp_query; ?>
<?php $get_children = $wpdb->get_results(‘SELECT * FROM wp_categories WHERE category_parent = “13” ORDER BY category_priority’); foreach ($get_children as $child) {
echo ‘- ‘.$child->cat_name.’
- ” rel=”bookmark” title=”<?php the_title(); ?>”><?php echo $pname; ?>
‘;
$categoryvariable=$child->cat_ID; // assign the variable as current category
$query= ‘cat=’ . $categoryvariable . ”; // concatenate the query
$the_new = query_posts($query); ?>
<li style=”list-style: none”>
<ul class=”children”>
<?php while (have_posts($the_new)) : the_post($the_new); ?><?php $pname = c2c_get_custom(‘Product Short Name’); if ($pname == ”) { echo ”;
} else { ?><?php } ?><?php endwhile; ?>
<?php } ?>
<div id=”applications”>
<ul id=”navlist”>
<?php wp_list_cats(‘child_of=30’); ?></div>
<div id=”sideinfo”>
<ul id=”navlist”>
<?php wp_list_cats(‘child_of=15’); ?></div>
</div>
<?php while (have_posts()) : the_post(); ?>
<?php if (is_single()) : ?>
<?php $str = c2c_get_custom(‘Sidebar Content’); echo stripslashes($str); ?>
<?php endif; endwhile; ?>
</div>
<?php $wp_query = clone $temp_query; ?>Any ideas?
Thanks for your help!
- The topic ‘2.1 – Multiple Queries’ is closed to new replies.