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 开发者_JAVA百科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?
You'll want to look at the wp_posts table for the post_status column. Anything with the status "publish" is what you want.
You may also want to look at using built-in wordpress functions. More info on that is at http://codex.wordpress.org/Integrating_WordPress_with_Your_Website.
精彩评论