October 25, 2017 at 3:18 pm #269
I am working on a blogging website. I need a function that I can send a mail to all my subscriber with information about the blog posts made in the current month only. Is there any function to workout the same.
January 10, 2018 at 3:58 pm #1100
You can work is out in 2 ways –
1. Use the following code with post meta of that specific post –
<?php $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 = 'post' AND $wpdb->posts.post_date > datepost ORDER BY $wpdb->posts.post_date DESC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?>
2. Use the following code if you want to use the timestamp with after parameter –
$post_date = get_the_date('H-i-s-m-d-Y', $last_post_id); $units = explode('-', $post_date); $timestamp = mktime($units, $units, $units, $units, $units, $units); $args = array( 'date_query' => array( 'after' => date('c', $timestamp) ), 'posts_per_page' => -1 );
Above codes are to be putup in the function.php file.
You must be logged in to reply to this topic.