selecting post in the current month
-
sorry but i have no idea of php, is there any way i can select only posts in the current month with this piece of code:
function mdv_recent_posts6($no_posts = 5, $before = '
- ', $after = '
', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = true, $cat='6') {
global $wpdb;
$time_difference = get_settings('gmt_offset');
$now = gmdate("Y-m-d H:i:s",time());
$request = "SELECT ID, post_title, post_excerpt,post_date,post_date_gmt FROM $wpdb->posts,$wpdb->post2cat WHERE ID=$wpdb->post2cat.post_id AND $wpdb->posts.post_status = 'publish' ";
if($hide_pass_post) $request .= "AND $wpdb->posts.post_password ='' ";
$request .= " AND $wpdb->post2cat.category_id=$cat ";
$request .= "AND post_date_gmt < '$now' ORDER BY $wpdb->posts.post_date DESC LIMIT $skip_posts, $no_posts";
$posts = $wpdb->get_results($request);
$output = '';
if($posts) {
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$output .= $before . '' . htmlspecialchars($post_title) . '';
if($show_excerpts) {
$post_excerpt = stripslashes($post->post_excerpt);
$output.= '' . $post_excerpt;
}
$output .= $after;
}
} else {
$output .= $before . "None found" . $after;
}
echo $output;
}
thanks
- The topic ‘selecting post in the current month’ is closed to new replies.