Date query year and month OR just year

You have not stated how the selection works, but you need to have some kind of conditional set when a specific month is selected and when a year archive is selected. I also do not know where get_the_time comes in or its relevance to the query. But anyways, there are some other really big issues … Read more

Add to previous posts under post

Try to add date_query to the $qry in the solution mentioned here. $qry = new WP_Query( array( ‘cat’ => $current_post_categories[0], ‘posts_per_page’ => 2, ‘post__not_in’ => array( $current_post_id ), ‘date_query’ => array( array( ‘before’ => $post->post_date, ), ), ));

How to combine tax_query and date_query in WordPress

I’m afraid that there is no way to do such advanced queries using WP_Query. But, of course, you can still achieve that result, but you’ll need to write a little bit more code. There are two solutions: It’s hard to give you precise code, because there aren’t many details in your question, but maybe this … Read more

Date Query to Pull Current and Future Posts

I wonder if you mean this kind of date_query: $query->set( ‘date_query’, [ [ ‘after’ => ‘today midnight’, ‘column’ => ‘post_date_gmt’, ‘inclusive’ => true, ], ] ); where we use the after attribute. Here the after date will be calculated by WP_Date_Query as: gmdate( ‘Y-m-d H:i:s’, strtotime( ‘today midnight’, current_time( ‘timestamp’ ) ) ); With the … Read more

Get only modified posts

You can use the posts_where filter: // Add custom filter add_filter( ‘posts_where’, ‘wpse_modified’ ); // Fetch posts $query = new WP_Query( $lastupdated_args ); where you can define the filter callback as: function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( current_filter(), __FUNCTION__ ); // Append custom SQL return $where . ” AND … Read more