我需要帮助来开发wordpress自定义。我有以下带有UNION
指令的mysql查询:
SELECT
wp_posts.*
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
LEFT JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id AND mt1.meta_key = 'dir_featured' )
WHERE
( wp_term_relationships.term_taxonomy_id IN (2151) ) AND
wp_posts.post_type = 'ait-dir-item' AND
((wp_posts.post_status = 'publish')) AND
(
(
wp_postmeta.meta_key = 'dir_featured' AND
CAST(wp_postmeta.meta_value AS CHAR) = 'yes'
)
)
GROUP BY wp_posts.ID
UNION
SELECT
wp_posts.*
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
LEFT JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id AND mt1.meta_key = 'dir_featured' )
WHERE
wp_term_relationships.term_taxonomy_id IN (2151) AND
wp_posts.post_type = 'ait-dir-item' AND
wp_posts.post_status = 'publish' AND
mt1.post_id IS NULL
GROUP BY wp_posts.ID
我想用wordpress参数翻译这个查询。有可能吗?
这个查询的目的是什么?这是您在Wordpress模式中的查询
$args = array(
'cat' => 2151,
'post_type' => 'ait-dir-item',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'dir_featured',
'value' => 'yes',
'compare' => '==',
),
),
);
query_posts( $args );