我正在嘗試在我的博客上獲取最新帖子。這些顯示在我的網站首頁上的一個小部件中。雖然我有點麻煩。帖子越來越多。 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中有正確的方式來做到這一點 –