我知道你可以使用wordpress方法获取特色图像,但是对于这个特定的项目,我需要通过mysql查询获取特色图像。谁能给我指出正确的方向吗。非常感谢。
到目前为止,这就是我所知道的,但我的查询并没有起到作用。我将$post->id存储为一个名为$da\\U id的变量
$Featured_image = $wpdb->get_results("
SELECT *
FROM net_5_postmeta
INNER JOIN net_5_posts ON net_5_postmeta.post_id=net_5_posts.ID
WHERE post_parent = $da_id
AND meta_key = \'_wp_attached_file\'
ORDER BY post_date
DESC LIMIT 15",\'ARRAY_A\');
最合适的回答,由SO网友:Eugene Manuilov 整理而成
$Featured_image = $wpdb->get_results("
SELECT p.*
FROM net_5_postmeta AS pm
INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID
WHERE pm.post_id = $da_id
AND pm.meta_key = \'_thumbnail_id\'
ORDER BY p.post_date DESC
LIMIT 15
",\'ARRAY_A\');