SQL Call to pull posts ONLY in certain categories
-
I am working with a plugin that I kinda pieced together from others which works very well. It is a recent posts plugin that displays certain info for the most recent posts. All that works; however, I cannot only pull based on category, which is vital to my application. Essentially, right now, the SQL query pulls all recent posts and I want to modify the SQL query to pull only recent posts in ONE category only. However, I am confused as to how to do this.
Here is the query I have currently, could someone take a look at it and possibly give me some direction? Thanks.
$request = $wpdb->prepare("SELECT ID, post_title, post_date, post_excerpt,LEFT(post_content,$sqllimit) AS short_post_content FROM $wpdb->posts WHERE post_status = 'publish' "); if($hide_pass_post) $request .= "AND post_password ='' "; if($include_pages) $request .= "AND (post_type='post' OR post_type='page') "; else $request .= "AND post_type='post' "; $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $returnnum";
Mike
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘SQL Call to pull posts ONLY in certain categories’ is closed to new replies.