Skip to content Skip to sidebar Skip to footer

WordPress custom query for get data from wp_post table

Reading Time: < 1 minutes

This mysql query help to get data from the wp_posts table of the wordpress.It will get any data from the wp_post table.Only you have to set the condition in the WHERE clause of this query.

SELECT post_title,guid,post_content
FROM wp_posts
 LEFT JOIN  wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
 LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
 LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_term_taxonomy.taxonomy = 'category' AND wp_term_taxonomy.term_id IN(1) AND
(post_title LIKE '%$search%' OR post_content LIKE '%$search%' OR post_name LIKE '%$search%')