#7226 closed defect (bug) (invalid)
Excluding category with query_posts reverses choronological order
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | high | |
| Severity: | critical | Version: | 2.5.1 |
| Component: | General | Keywords: | |
| Focuses: | Cc: |
Description
Whenever I use query_posts('cat=-3') to exclude category #3, the choronological order of the posts is reversed. The choronological order is maintained when I use query_posts('cat=3') with any other paramter. I had tried to use orderby=date and order=DESC/ASC parameters with query_posts but no changes occur.
I am using PHP 5.2.5 with MySQL 5.0.51a on Windows.
Here's the full code:
<?php get_header(); ?>
<div id="col-1" class="narrowcolumn">
<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-3paged=$page&orderby=date&order=DESC");
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$at_id = get_the_category($post->ID);
$cat_id = $cat_id[0]->term_id;
?>
<?php if($cat_id == 3) { ?>
<div class="<?php echo ($post == $posts[1]) ? 'post featured' : 'post'; ?>" id="post-<?php the_ID(); ?>">
<?php } else { ?>
<div class="<?php echo ($post == $posts[0]) ? 'post featured' : 'post'; ?>" id="post-<?php the_ID(); ?>">
<?php } ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt('Read the rest of this entry »'); ?>
<a href="<?php the_permalink() ?>" class="button">Read More</a>
</div>
<?php endwhile; ?>
<?php
/**
* If more than one page exists, return TRUE.
*/
function show_posts_nav() {
global $wp_query;
return ($wp_query->max_num_pages > 1) ? TRUE : FALSE;
}
if (show_posts_nav()) {
?>
<div class="navigation">
<div class="nav-1 nav"><?php next_posts_link('« Older Entries') ?></div>
<div class="nav-2 nav"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php } ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.
<?php include (TEMPLATEPATH . "/searchform.php"); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Note: See
TracTickets for help on using
tickets.
Replying to isharis:
Upgrade MySQL to a version without that bug.
http://wordpress.org/support/topic/154622
http://bugs.mysql.com/bug.php?id=32202