我正在尝试在我的博客上获取最新帖子。这些显示在我的网站首页上的一个小部件中。虽然我有点麻烦。帖子越来越多。 http://goo.gl/Q2STSC,这是我的SQL查询。在我的网页上从我的wordpress获取最新帖子
$posts = DB::connection('blog')->select("
SELECT a.post_title AS title, a.post_name AS slug, meta_value AS thumbnail,a.post_content AS contenido, a.post_date AS fecha
FROM wp_postmeta, wp_posts AS a
JOIN wp_posts AS b ON a.ID = b.post_parent
WHERE b.ID = wp_postmeta.post_id
AND meta_key = '_wp_attached_file' AND a.post_status = 'publish'
ORDER BY fecha
LIMIT 0 , 6");
请解释为什么你正在使用一个自定义的sql查询。在wordpress中有正确的方式来做到这一点 –