WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to add sorting but don't have any idea how ot go about it. I would like to be able to sort by:

Date, Title, Price (custom field), Comments, Views, ASC + DESC

What would be the best way to do something like this?

share|improve this question
Check if this could help you - wordpress.stackexchange.com/q/57850/17968 – amit Aug 19 '12 at 15:43
can you paste more information like the loop of the page / post where you want to add sorting – Sagive SEO Aug 19 '12 at 16:53
@SagiveSEO like what? – Joe Bobby Aug 19 '12 at 17:31
@amit i tried site.com/?orderby=title&order=dsc and it went the the blog page and sorted.. this is a custom post type how do i get it to sort on the same page? – Joe Bobby Aug 19 '12 at 17:37
you can pass an extra parameter post_type, See my answer below – amit Aug 19 '12 at 18:45
up vote 0 down vote accepted

Extending this answer for custom post type support.

For a custom post type you can pass an extra parameter ( post_type ) to url, example -


Note - If you've specified some url rewrite for that post type then the above url will become something like this but still showing all posts of post type FOO with descending order by title.

share|improve this answer
this works, but is there any php I can add for sorting? I only got it to work by trying <a href="http://site.com/?post_type=portfolio&orderby=title&order=dsc">test</a> – Joe Bobby Aug 19 '12 at 22:05
I didn't get you ? Do you want get this done without using url parameters ? I think this is best way to make posts sortable using a click. – amit Aug 19 '12 at 22:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.