Forums

How to implement drop down sort by title, date, custom field, etc? (3 posts)

  1. Jacorre
    Member
    Posted 5 months ago #

    I'm having trouble understanding how to implement a drop down sort option so users can sort posts by title, date, custom field, etc. I'm using a custom post type with custom taxonomies and fields.

    I know you can create a template and use query_posts or wp_query and define the orderby but that's a one time deal.

    If the user selected a specific category let's say, by default it would sort by date, but I want to provide a drop down where they could instead select title and those same posts will now be sorted by title instead of date.

    I tried WP Smart Sort but it's not working.

    Any suggestions or tutorials? Thank you!

  2. Jacorre
    Member
    Posted 5 months ago #

    Think I just realized what I was missing. You can manipulate the url to include the orderby and order values. Interesting, I think I got it!

  3. Jacorre
    Member
    Posted 5 months ago #

    If a user performs a search the url will have the search values. For example, ?s=searchphrase&taxonomy=whatever.

    Then I have the sort options they could use and submit, which should just add the orderby and order values to the end of the url. For example,

    ?s=searchphrase&taxonomy=whatever&orderby=title&order=asc

    But I can't get the original url to stay while the orderby and order values are being appended.

    Any way to do that?

Reply

You must log in to post.

About this Topic