Order from the First to the Lastest Post (7 posts)

  1. Anonymous
    Posted 12 years ago #

    In one template I want to show the post in the normal order (First the newews) and in the other template show in the opposite way (First the Oldest).
    My php skills are worse than my english so...
    Any help?

  2. Julian
    Posted 12 years ago #

    Stick <?php $order = "ASC"; ?> in your template. If that doesn't work, reference the template (like an archive) like this: http://yoursite.com/template.php?order=ASC

  3. GM20XX
    Posted 12 years ago #

    Thanks! It worked perfectly :)

  4. cavlec
    Posted 11 years ago #

    Note that if you have a RewriteRule in your .htaccess creating friendly permalinks, referencing the template in the URL you type into your browser won't work. What you want to do instead is add "&order=ASC" to the rule in .htaccess, thusly (for a category archive):
    RewriteRule ^archives/category/?(.*) /index.php?category_name=$1&order=ASC [QSA]
    or thusly (for a month/year archive):
    RewriteRule ^archives/([0-9a-z-]+)?/?([0-9]+)?/?$ /index.php?name=$1&page=$2&order=ASC [QSA]
    Hope this helps someone.

  5. davidchait
    Posted 11 years ago #

    And just since it's been a problematic thing to implement, note that the $order='ASC' must come BEFORE the wp-blog-header include for it to actually work. :)

  6. rdub
    Posted 9 years ago #

    Would <?php $order = "ASC"; ?> go in the templates.php file?

  7. Joshua Sigar
    Posted 9 years ago #

    It goes to the file index.php in the root directory (NOT theme directory) of WP installation

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.