This is my query
SELECT P.ID, P.post_title, P.post_content, P.post_author,
MAX(IF(PM.meta_key = 'ex_latitude', PM.meta_value, NULL)) AS lat,
MAX(IF(PM.meta_key = 'ex_longitude', PM.meta_value, NULL)) AS lng
FROM wp_posts AS P
LEFT JOIN wp_postmeta AS PM on PM.post_id = P.ID
WHERE P.post_type = 'post' and P.post_status = 'publish'
ORDER BY P.ID DESC
Result only one post data row
+-----+------------+--------------+-------------+-----------+---------------+
| ID | post_title | post_content | post_author | lat | lng |
+-----+------------+--------------+-------------+-----------+---------------+
| 10 | Post Title | Post Content | 1 | 56.00078 | 26.45677 |
+-----+------------+--------------+-------------+-----------+---------------+
But how return all posts?
WP_Query
query. Why don't you use it?ex_latitude
orex_longitude
metadata, right?