how do I get all posts and postmetas in an associative array?
$allposts = $wpdb->get_results("
SELECT $wpdb->posts.post_title, $wpdb->postmeta.meta_key
FROM $wpdb->posts
JOIN $wpdb->postmeta
ON $wpdb->postmeta.post_id = $wpdb->posts.id
WHERE $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status ='publish';", OBJECT_K);
I just don’t get it….
Basically, you can’t do it in a single SQL query. You need two.
You don’t have to make direct queries though, since you can use get_post() and get_post_custom().