使用WP_Query或$ wpdb变量创建SQL查询

时间:2017-07-17 19:18:11

标签: sql wordpress posts

我使用WP_query或$ wpdb创建以下查询以根据特定层次结构排序所有帖子:

select *
from postTable
where tag = 'tag1'
order by category, tag2, date
union
select *
from nometabella
where tag <> 'tag1'
order by category, 'tag2', date

其中tag1tag2是标记。通过这种方式,帖子按特定顺序显示

(first posts with tag1 grouped by category, tag2 and date, then posts grouped by category and, for each category, they are grouped by tag2 and date)

请帮帮我吗?

0 个答案:

没有答案