1
votes

I have a custom type on a wordpress site I've developed. The type is called called "book"

It has a field called "book_year" I've just added a field called book_month (int 1-12)

The query to retrieve all "books" is currently:

$query .= 'post_type=books&posts_per_page='.$perpage.'&paged='.$paged.'&orderby=meta_value&meta_key=book_year&order=DESC';

What I want to do is order by book_year, then by book_month (so that January (1) appears before June (6) )

I take it it's the orderby part that needs changing, I'm just not sure as to what...

1
That's all the code you are using? How is the $query transformed into a SQL query?ypercubeᵀᴹ
I only posted the relevant part... the rest of the query is generated further upAlex
Perhaps the question should be transfered to wordpress.stackexchange.com/.ypercubeᵀᴹ

1 Answers

1
votes

Your code should result in building this in the query:

ORDER BY book_year, book_month