Change Post Order in Categories (2 posts)

  1. dgchichester
    Posted 10 years ago #

    I've searched and read a number of messages here relating to post order, and have successfully been able to change to chronological order of my blog's posts on a global basis by doing this to the index.php file:

    /* Short and sweet */
    $order = "ASC";
    define('WP_USE_THEMES', true);


    However, I would like to find out if this can be done for a SINGLE category -- say it's called "Max" What is the code I would need to accomplish this? And where would I place the code. I have attemted an "if" statement bfore the order line, but my skills in this area did not result in success. I'd appreciate any guidance -- the more explicit the better.


  2. Kafkaesqui

    Posted 10 years ago #

    If not using custom permalinks:

    if (isset($_GET['cat'])) {
    if('CATNUM' == $_GET['cat']) {
    $order = 'ASC';

    Change CATNUM to the numeric ID for the category. Something like this should work when using custom permalinks :

    if (preg_match("/max/", $_SERVER['REQUEST_URI'])) {
    $order = 'ASC';

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.