[wp-trac] [WordPress Trac] #7226: Excluding category with
query_posts reverses choronological order
WordPress Trac
wp-trac at lists.automattic.com
Wed Jul 2 16:53:12 GMT 2008
#7226: Excluding category with query_posts reverses choronological order
----------------------+-----------------------------------------------------
Reporter: isharis | Owner: anonymous
Type: defect | Status: new
Priority: high | Milestone: 2.6
Component: General | Version: 2.5.1
Severity: critical | Keywords:
----------------------+-----------------------------------------------------
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(); ?>
}}}
--
Ticket URL: <http://trac.wordpress.org/ticket/7226>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list