WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Anonymous
    Unregistered
    Posted 11 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
    Member
    Posted 11 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
    Member
    Posted 11 years ago #

    Thanks! It worked perfectly :)

  4. cavlec
    Member
    Posted 10 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
    Member
    Posted 10 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. :)
    -d

  6. rdub
    Member
    Posted 8 years ago #

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

  7. Joshua Sigar
    Member
    Posted 8 years ago #

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


    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    $order = 'ASC';
    require('./wp-blog-header.php');
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.