Wordpress, Category, Order

Published: Tue 08 January 2008
By Author

In meta.

I spent a couple of hours just now trying to figure how to set order to categories in Wordpress, mostly because every time I give someone a link to my ef category, I want them to read it in chronological order.

As it turns out, the only way to do it is to write a plugin. It seems like a monstrous overkill for such a small purpose, but I found no other way to customize a query. Fortunately, it's very simple:

<?php
/*
Plugin Name: Order
Description: Set category order to ascending
Author: Author
Version: 1.0
*/ 

add_action('pre_get_posts', 'order_set_ascending' );

function order_set_ascending( $notused )
{
  if( is_category() ) {
    set_query_var('order', "ASC");
  }
}
?>

P.S. Unfortunately, posts_nav_link() displays the next page link on the left, which gives the whole setup a feel of scanlated manga.

UPDATE: Evirus reminded me about this thing... Yes, navigation is screwed, although I hacked the theme to make sure that it's not too broken using is_category(). It would be much better if Wordpress supported this natively, with the navigation link generators working, etc.

UPDATE: Far away no where also looked at it, added tweaks.

links

social