这是一个SQL问题。您的查询错误。您忘记在查询中包括term\\u relationships表,但在联接期间引用了它。通过包含term\\u relationships表,可以解决查询问题。
SELECT ID, post_title, post_content, post_date
FROM {$wpdb->posts} AS p
JOIN {$wpdb->term_relationships} AS tr
ON tr.object_id = p.id
JOIN {$wpdb->term_taxonomy} AS tt
ON tt.term_taxonomy_id = tr.term_taxonomy_id
WHERE tt.term_id = 18
AND tt.taxonomy = \'category\'
AND post_status = \'publish\'
AND post_type = \'post\'
ORDER BY post_date DESC
LIMIT 25