I have this queary were I’m grabbing all post types of “news” in 2010, but it doesn’t select the posts from that year. What am i doing wrong?
$querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'news' AND year($wpdb->posts.post_date) = 2010, ORDER BY $wpdb->posts.post_date DESC ";
Taking this line out does grab the news posts, but really I want them from a particular year.
AND year($wpdb->posts.post_date) = 2010,
- The topic ‘Custom Select Query – Selecting the Year?’ is closed to new replies.