WordPress – Exclude ‘draft’ posts from Lastest Blog posts list

Im working with the worst wordpress code here, essentially there is a mysql query running to fetch a list of latest blog posts:

$query3="select p.post_title, wpr.object_id, wp_terms.name, p.post_date, p.post_content, p.ID
from wp_terms
inner join wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
inner join wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
inner join wp_posts p on p.ID = wpr.object_id
where taxonomy= 'category' and p.post_type = 'post' and wp_terms.name = 'blog' 
order by p.post_date DESC LIMIT 4;";
$result3 = mysql_query ($query3);

However this is also returning a list containing posts which are set as ‘Draft’. Anyone know the table name and column name I need to adjust the above query to not show draft blogs posts?

Related posts

Leave a Reply

1 comment