Support

Account

Home Forums General Issues Query for posts with the same day and month in the past Reply To: Query for posts with the same day and month in the past

  • Hi Rafaromo,

    You could use this

    $args = array (
        'post_type' => 'YourPostType',
        'meta_query' => array(
    		array(
    	        'key'		=> 'start_date',
    	        'compare'	=> '=',
    	        'value'		=> $TheDateYouAreLookingFor,
    	    )
        ),
    );
    
    // get posts
    $posts = get_posts($args);

    I got this from the ACF guide: https://www.advancedcustomfields.com/resources/date-picker/

    The can also be used with the regular WP Query. The date you are looking for needs to be in the same format as the custom field date that is saved to the database.

    Hope this helps,
    Neasa