• Resolved Mickstah

    (@mickstah)


    I have a custom post type for award recipients, and a custom taxonomy ‘year’ so that I can sort the winners into the years that they won.

    I’m using the following code to show this info:
    http://pastebin.com/H2rLUqb4

    My problem is that whilst the Recipients themselves are being sorted how I wish, the taxonomy ‘year’ titles are not. They are sorting by numerical order ie:

    2008 Recipients
    2009 Recipients
    2010 Recipients

    If I add ‘2007 Recipients’ it will just to the top of the sort, but if I change the title to ‘2011 Recipients’ it will move to the bottom. I wish to control the orderby here but I’m unsure how to do it.

Viewing 1 replies (of 1 total)
  • Thread Starter Mickstah

    (@mickstah)

    So I managed to solve this myself.

    Where I was using get_term to grab the custom taxonomy year get_terms('year') I added an array so I could use orderby-
    <?php $years = get_terms('year', array( 'orderby' => 'title', 'order' => 'DESC', ));

    So the full code now looks like this:

    http://pastebin.com/NyN3UrF3

    Perfect!

Viewing 1 replies (of 1 total)

The topic ‘Sorting a Custom Taxonomy & Post Type’ is closed to new replies.