星期四, 8月 18, 2016

[Wordpress] 使用自訂的sql抓取WMPL翻譯的文章類型

記錄如何自已下sql取得文章的多國類型,裝的外掛為WMPL。
請注意WMPL此外掛是將翻譯的關連資訊存到mywp_icl_translations



以下為sql語句


select
posts.ID,
posts.post_name,
posts.post_date,

IFNULL((SELECT PM.meta_value FROM mywp_postmeta AS PM WHERE posts.ID = PM.post_id AND PM.meta_key = "your_post_type"),'') as link,
IFNULL((SELECT PM.meta_value FROM mywp_postmeta AS PM WHERE posts.ID = PM.post_id AND PM.meta_key = "_thumbnail_id"),'') as thumbnail_id

FROM mywp_posts AS posts
where
post_status = 'publish'
AND
post_type = 'emel_ad_slider'
AND
ID
IN
(
select element_id from mywp_icl_translations
where element_type = 'post_your_post_type' and language_code = 'zh-hans'
)
order by posts.post_date desc

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails