0

How to fetch all meta_key and meta_value using post_id wihout duplication of post meta using sql query.

This query is repeting the post meta each time .

$sql="SELECT * FROM wp_posts
LEFT JOIN wp_postmeta
ON wp_posts.ID= wp_postmeta.post_id
where post_type='property'"; 
1

You don't need to write a custom SQL for this. You can always leverage WP's get_post_custom() that returns array of all custom fields for a particular page or post.

https://codex.wordpress.org/Function_Reference/get_post_custom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.