按多个排序 - 对于 wordpress 属性
我在我开发的 WordPress 网站上有一个自定义类型。 该类型称为“book”,
它有一个名为“book_year”的字段 我刚刚添加了一个名为 book_month (int 1-12) 的字段
检索所有“书籍”的查询当前为:
$query .= 'post_type=books&posts_per_page='.$perpage.'&paged='.$ '&orderby=meta_value&meta_key=book_year&order=DESC';
我想做的是按 book_year 排序,然后按 book_month 排序(以便一月 (1) 出现在六月 (6) 之前)
我认为这是需要更改的 orderby 部分,我只是不确定什么......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码应该导致在查询中构建此内容:
Your code should result in building this in the query: