Display posts on today’s date
-
Hi
I am attempting to develop a page template for a category that allows the display of posts that were published on the same date (excluding the year). e.g. For today it would display all posts dated 8th February. I have code for this which is:
add_action('pre_get_posts', 'cgy_same_day'); function cgy_same_day($query) { if ($query->is_home() && $query->is_main_query()) { $today = getdate(); $query->set('date_query', array( array( 'day' => $today['mday'], 'month' => $today['mon'], ), )); $query->set('post_status' , array('publish','future')); } return; }
Is it possible to use this code to display posts as required please?
Thanks
Rich
The page I need help with: [log in to see the link]
- The topic ‘Display posts on today’s date’ is closed to new replies.