Support » Fixing WordPress » Toggle Archive Order between Ascending Descending

  • I have two archive pages that display just the titles of my posts. They’re identical, except one lists the posts from oldest to newest, and the other lists the posts from newest to oldest. I have links at the top of the page like this:
    [oldest first | newest first ]
    To switch between the two pages.

    I imagine there’s a more elegant way of doing this than having two different versions of the same page and hard links to each, but I don’t know what it is.

    So, is there a way to code a link to switch from
    <?php $archive_query = new WP_Query(array(‘showposts’ => ‘1000’,’orderby’ => ‘date’, ‘order’ => ‘DSC’));
    to
    <?php $archive_query = new WP_Query(array(‘showposts’ => ‘1000’,’orderby’ => ‘date’, ‘order’ => ‘ASC’));
    and back again, within the same page?

    Thanks!

  • The topic ‘Toggle Archive Order between Ascending Descending’ is closed to new replies.