• Resolved kingofmycastle

    (@kingofmycastle)


    Hi, I’ve been using your plugin on a few sites and I’m really happy with its ease of use. But I am stuck on one thing.

    I have a date field which seems to store the date in the following format: YYYY-MM-DD

    Now I am running a custom query and I need to retrieve all posts AFTER a certain date. Do you know if this is possible? Here is the type of query I’m trying to use:

    $args = array(
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		array(
    			'key' => 'date_of_workshop',
    			'value' => '2014-05-10',
    			'compare' => '>=',
    			'type' => 'DATE'
    		)
    	)
    );

    I’ve tried to use different types such as NUMERIC & DATETIME, as well as changing the value to ‘Y-m-d H:i:s’ but I’ve had no luck.

    Is there a native WP way to do this or will I a) have to retrieve ALL posts and filter by the date field, or b) run a manual SQL query?|

    Thanks for all your effort!

    John..

    https://www.ads-software.com/plugins/custom-field-suite/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to WP_Query filter by a date field?’ is closed to new replies.