Support » Plugins » Reverse order posting

  • Can this be done in WP?
    I have a blog set to posts paged but I want the posts to show the oldest first.
    Have hunted but cannot find a mention of it.
    Anyone like to point me in the right direction?

Viewing 15 replies - 1 through 15 (of 18 total)
  • Reverse order posts:
    This is from the first post ever, not the first post of the day.

    Open wp-blog-header.php
    Look for this line:

    $where .= $search.$whichcat.$whichauthor;
    if ((empty($order)) || ((strtoupper($order) != 'ASC') && (strtoupper($order) != 'DESC'))) {

    It will be a little more than half way down.
    Add the following right after that.
    If you want to change the order on some categories, try this:

    if ('11' == $cat) {

    Changing the 11 to any cat you want.
    If you want to change the order for all posts in all categories then remove the first & third lines of the above code.
    If you check out my site, you’ll see that most of the site is ordered normaly – newer first. But any of the sections under Writtings & Scribblings are ordered Oldest first.

    Sorted..Thanks all
    as stated by the above posts on about line 680’ish in wp-blog-header.php:
    $order='DESC'; changed to $order='ASC';
    Damn that was easy 🙂
    :another happy wp user:

    In version 1.5 (just installed) the code isn’t in wp-blog-header.php but I found it in wp-includes/classes.php on line 460.

    I can get it to change the order on all categories, simply by changing ‘DESC’ to ‘ASC’ but the change to some categories doesn’t seem to work, presumably because the variable isn’t called $cat any more?

    Roger Cornwell

    Well, a lack of responses to my post (above) led me to investigate further. And it seems to be surprisingly simple. In the example above, instead of

    if ('11' == $cat) {

    you need to code

    if ('11' == $q['cat']) {



    Here is how to RECURSIVELY reverse-order a group of categories, by hacking .htaccess.



    Okay, howto?

    In my .htaccess, I put this:
    RewriteRule ^category/(world-tour.+)/?$ /index.php?category_name=$1&order=ASC [QSA,L]

    Right before this line:
    RewriteRule ^category/(.+)/?$ /index.php?category_name=$1 [QSA,L]

    Ditto for chronological archives:
    RewriteRule ^(archive)/?([0-9]+)?/?$ /index.php?pagename=$1&page=$2&order=ASC [QSA,L]

    I recently added paged category archive posting. I realized things eren’t working quite right, so now my .htaccess has been amended:

    # Reverse-Order pages within world-tour/
    RewriteRule ^category/(world-tour.*)/page/?([0-9]{1,})/?$ /index.php?category_name=$1&paged=$2&order=ASC [QSA,L]
    RewriteRule ^category/(.+)/page/?([0-9]{1,})/?$ /index.php?category_name=$1&paged=$2 [QSA,L]
    # Reverse-Order pages within world-tour/
    RewriteRule ^category/(world-tour.*)/?$ /index.php?category_name=$1&order=ASC [QSA,L]
    RewriteRule ^category/(.+)/?$ /index.php?category_name=$1 [QSA,L]



    This is why I love WP. I just decided I needed to reverse order
    posts in some categories and it took me all of about 2 minutes
    to find 2 different solutions.

    Thank you all – the forums are terrific and WP rocks.

    Thank you to Cornwell : that is the solution !
    Just a note : use ‘ASC’ instead of ‘DESC’, if not the code is added for nothing !!!

    ASC will do the job indeed. You can also try and write your own function. Fairly easy even without PHP knowledge.

    How woudl I accomplish this in WP 2.0? I want to chronologically list my archives (probably specifically)…

    There is no need to be editing core files or rewrite rules here people.

    Just use this right above your Loop:

    See also (same kinda thing, but this example sorts by title rather than date):

    The correct code for wp2.01 is:

    if ((empty($q[‘order’])) || ((strtoupper($q[‘order’]) != ‘ASC’) && (strtoupper($q[‘order’]) != ‘DESC’))) {

    type: (change 23 to your category number)

    if (’23’ == ($q[‘cat’])) {

    How would this be done by a a user selection?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Reverse order posting’ is closed to new replies.