所以我有以下查询有效,但我还需要帖子特色图片,你们也可以帮助我进行查询。
SELECT SQL_CALC_FOUND_ROWS wp_posts。*
从wp_posts,wp_term_relationships,wp_terms
在哪里wp_posts.ID = wp_term_relationships.object_id和wp_posts.post_status ='发布'
AND wp_terms.term_id = wp_term_relationships.term_taxonomy_id GROUP BY wp_posts.ID ORDER BY
wp_posts.post_date DESC LIMIT 0,100
最佳答案
我最近不得不检索带有特色图片的最新4篇帖子,发现这确实很困难。这段代码对我有用(最后),我知道它可能并不准确,但是无法在评论中发布,并且我相信它将有所帮助:
SELECT title, name, date, content, CONCAT(LEFT(image, LENGTH(image) - LOCATE('.', REVERSE(image))),'-768x576.',SUBSTRING_INDEX(image, '.', -1)) AS image
FROM (
SELECT
p.post_title AS title,
p.post_status AS 'status',
p.post_date AS date,
p.post_content AS content,
p.post_name AS name,
(SELECT `guid` FROM wp_posts WHERE id = m.meta_value) AS image
FROM wp_posts p, wp_postmeta m
WHERE p.post_type = 'post'
AND p.post_status = 'publish'
AND p.id = m.post_id
AND m.meta_key = '_thumbnail_id'
LIMIT 4
) TT
关于php - Wordpress MySQL也查询特色图片,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43294769/