WordPress.org

Ready to get started?Download WordPress

Forums

Help with Single Archive and Multiple Views (orderby) (2 posts)

  1. holdstrong
    Member
    Posted 2 years ago #

    Hi all,

    I am really stuck on this one.

    I understand how to sort an archive page (or category, or search) by different criteria... such as by title.

    However, what I need to be able to do is have multiple views, or instances, of the same archive page all with different orders.

    So, for example. The default is orderby date. I want to keep that. But I then want the user to be able to go to another page and see the SAME archives ordered by title. And then maybe go to yet another page, and see the SAME archives but this time ordered by a custom field.

    In my head, this would require 3 archive pages with 3 different loops. How do I do this though given the way wordpress handles template hierarchies? Each archive, or category, has but 1 archive page that wordpress grabs and uses.

    Thanks in advance for any help

  2. patv
    Member
    Posted 2 years ago #

    You can do this through one page, if all your changing is the column you're ordering by and its direction. For the links pointing to these different requests, append these parameters into the url, such that :

    www.somewebsite/archive/?orderby=title&order=DESC

    will order the posts by title in descending order. In your archive page, handle these parameters using the $_GET[] global variable and inject these into a custom wordpress query.

    Add some default values in case the parameters aren't defined and you're done :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.