WordPress SQL自定义查询获取帖子,发布元数据,类别和帖子的特色图片。
到目前为止,我已尝试过以下代码并获得了帖子和帖子后的元数据。现在分类和特色图片仍然存在:
.python-version
我自己修改了代码。在此代码类别中,现在只需要特色图像附件网址。
$query = mysql_query("
SELECT wp_posts.ID
, wp_posts.post_title
, mt1.meta_value as latitude
, mt2.meta_value as longitude
, mt3.meta_value as full_adddress
FROM wp_posts
LEFT JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id AND mt1.meta_key='lv_listing_lat')
LEFT JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id AND mt2.meta_key='lv_listing_lng')
LEFT JOIN wp_postmeta AS mt3 ON (wp_posts.ID = mt3.post_id AND mt3.meta_key='_address')
WHERE wp_posts.post_type = 'lv_listing'
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
AND ((mt1.meta_key = 'lv_listing_lat') OR (mt2.meta_key = 'lv_listing_lng' ) OR (mt3.meta_key = '_address' ))
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC ");