Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#7226 closed defect (bug) (invalid)

Excluding category with query_posts reverses choronological order

Reported by: isharis's profile isharis 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 &raquo;'); ?>
				<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('&laquo; Older Entries') ?></div>
			<div class="nav-2 nav"><?php previous_posts_link('Newer Entries &raquo;') ?></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(); ?>

Change History (5)

#1 @isharis
16 years ago

  • Owner changed from anonymous to isharis
  • Status changed from new to assigned

#2 @isharis
16 years ago

  • Owner isharis deleted
  • Status changed from assigned to new

#3 in reply to: ↑ description @Otto42
16 years ago

Replying to isharis:

I am using PHP 5.2.5 with MySQL 5.0.51a on Windows.

Upgrade MySQL to a version without that bug.

http://wordpress.org/support/topic/154622

http://bugs.mysql.com/bug.php?id=32202

#4 @Otto42
16 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#5 @lloydbudd
16 years ago

  • Milestone 2.6 deleted
Note: See TracTickets for help on using tickets.