SELECT
IF (POSITION('Villa' IN p.post_title)>=1,
SUBSTRING(p.post_title, 7), post_title) AS 'Title',
p.post_title,
p.ID,
p.post_content
FROM wp_posts p INNER JOIN wp_term_relationships tr
ON p.ID=tr.object_id where tr.term_taxonomy_id=4
and p.post_status='publish'
ORDER BY Title ASC;
我可以运行上面的查询,以获得与“WPDB”功能像如何使用此自定义MySQL查询作为Wp_query对象检索数据?
$wpdb->get_results($query);
但我需要返回的Wp_query对象上面的结果,因为我想使用的功能,如get_the_excerpt()