我有这个自定义查询,我需要这样做来检查 post_metadata 值和分类术语。我正在使用从 Wordpress 的 codex 修改的代码,但它始终返回零结果。我犯了一个错误吗?(更新:显示它首先被加载到变量中的位置)
global $wpdb;
$querystr = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
WHERE $wpdb->terms.name = '" . $service . "'
AND $wpdb->term_taxonomy.taxonomy = 'Services'
AND $wpdb->postmeta.meta_value = '" . $county . "'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->postmeta.meta_key = 'order'
ORDER BY $wpdb->postmeta.meta_value ASC";
$pageposts = $wpdb->get_results($querystr, OBJECT);