Support » Fixing WordPress » Sort custom post-types by taxonomy term slug

  • I have a taxonomy of ‘services’ created. I am returning all posts that are associated with ‘services’. I would like to know how I can sort these posts by the term slug of which service they are associated with.

    For instance,

    Taxonomy = ‘services’

    Term slugs = website, video, interactive

    How could I return these posts with all the websites on the top of a list, the video posts next, and then finally the interactive posts.

    I’ve gone around and around on how to do this. Please help, as I’m getting glares from the boss in getting this done!

Viewing 1 replies (of 1 total)
  • It looks like you could use ‘services’ as a meta_key and set orderby to ‘meta_value’ and order to ‘DESC’.

    If that does not work, I think the next approach would be to add a field to the query that is calculated based on the value of the slug and then use that as the primary sort field.

    You might get more specific help if you post the query that you are currently using.

Viewing 1 replies (of 1 total)
  • The topic ‘Sort custom post-types by taxonomy term slug’ is closed to new replies.