Categories link does not work when posts are displayed by Wp_Query
-
Hi all,
i’ve once again hit a road block in wordpress… right now i’m displaying my posts using WP_Query so that i can have control of displaying the posts by categories. On the sidebar is where i have the list of the categories i have ( <?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0’); ?> ) .
The problem: Everytime i click on the categories on my sidebar, it doesnt seem to load any of the articles from that category. it just displays the default posts when you load the website. i tried taking out the wp_query code and used the regular “if /while have posts code” and the category links worked pretty well.
i’ll attach the code that i have:
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query(‘cat=3&showposts=10′.’&paged=’.$paged);
?><?php while ($wp_query->have_posts()) : $wp_query->the_post();
$img = get_post_meta($post->ID, ‘img’, $single = true);
$img_class = get_post_meta($post->ID, ‘img class’, $single = true);
?><div id=”headline” class=”clearfix”>
<div class=”headline_box”>
<div id=”headline_title” class=”clearfix”>
<div class=”headline_title_left”><h2>“><?php the_title(); ?></h2></div>
<div class=”headline_title_right”><h3><?php the_date(); ?> <?php the_time(); ?></h3></div>
</div>
<div class=”headline_content_box”>
<div class=”img_box”>
<?php if($img !== ”) { ?><img src=”<?php echo $img; ?>”class=”<?php if($img_class !== ”) { echo $img_class; } else { echo “left”; } ?>” border=”1″ /><?php } else { echo ‘<div class=”no_image”><p>No Image Available.</p></div>’; } ?>
</div>
<div class=”text_box”><p><?php wswwpx_content_extract ( ‘Read more’, 55); ?></p>
</div>
</div>
</div>
</div>
<div class=”spacer”></div>
<?php endwhile; ?>
</div>
<div id=”sidebar_wrap”><div class=”sidebar_content_box”>
<h1>Boxing Headline Archives</h1><ul class=”archive-list”>
- <?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0’); ?>
</div>
So anyone with any suggestions or help will be deeply appreciated. Thanks guys!
- The topic ‘Categories link does not work when posts are displayed by Wp_Query’ is closed to new replies.