How to run database Query in WordPress?

How to run database Query in WordPress?

Team Leader Asked on February 11, 2017 in WORDPRESS.
Add Comment
1 Answer(s)

<?php
$querystr = "SELECT $wpdb->posts.*

FROM $wpdb->posts, $wpdb->postmeta

WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id

AND $wpdb->postmeta.meta_key = 'tag'

AND $wpdb->postmeta.meta_value = 'email'

AND $wpdb->posts.post_status = 'publish'

AND $wpdb->posts.post_type = 'post'

AND $wpdb->posts.post_date < NOW()

ORDER BY $wpdb->posts.post_date DESC";
$posts = $wpdb->get_results($querystr, OBJECT);
?>

Team Leader Answered on March 9, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.