Title: Get posts after a specific date
Last modified: August 31, 2016

---

# Get posts after a specific date

 *  Resolved [bgnjqw](https://wordpress.org/support/users/bgnjqw/)
 * (@bgnjqw)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/)
 * Hi,
 * How can I get the posts after a specific date?
 * I was try like this: wp-json/wp/v2/posts?filter[post_date__after]=2016-02-01T05:
   00:28
    but does not work.
 * Any help? Thanks!
 * [https://wordpress.org/plugins/rest-api/](https://wordpress.org/plugins/rest-api/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-7082364)
 * [In the next beta](https://github.com/WP-API/WP-API/issues/2144), Beta 13, you’ll
   be able to use `before` and `after` parameters for post collection queries:
 *     ```
       wp-json/wp/v2/posts?after=2016-02-01T05:00:28
       ```
   
 * If you don’t want to wait until the next beta is released, you can clone or download
   the `develop` branch from Github.
 *  Thread Starter [bgnjqw](https://wordpress.org/support/users/bgnjqw/)
 * (@bgnjqw)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-7082513)
 * Hi, I have try the develop branch, the after worked!
    but it seemed that the 
   before and after depend on date(with timezone), if I can use after and before
   on date_gmt.
 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-7082521)
 * > but it seemed that the before and after depend on date(with timezone), if I
   > can use after and before on date_gmt.
 * Right. `before` and `after` uses the `date` field, not `date_gmt`.
 *  Thread Starter [bgnjqw](https://wordpress.org/support/users/bgnjqw/)
 * (@bgnjqw)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-7082527)
 * I do not know the wordpress instance timezone and I just have a gmt time, can
   I get posts by date_gmt field? or any workaround?
    Thanks
 *  Plugin Author [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-7082535)
 * You can choose a different column to run the query against with `filter[date_query[
   column]]`:
 *     ```
       wp-json/wp/v2/posts?after=2016-02-01T05:00:28&filter[date_query[column]]=post_date_gmt
       ```
   
 *  [bbabics](https://wordpress.org/support/users/bbabics/)
 * (@bbabics)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-8410812)
 * This is exactly what I’m looking to do using `Version 2.0-beta15` with a custom
   post type that inherits from the `WP_REST_Posts_Controller`, but sorts based 
   on an acf field. Unfortunately this isn’t working for me. 🙁
 * I’m hitting the following endpoint:
    `/wp-json/wp/v2/almanac_entry?per_page=3&
   filter[orderby]=acf_almanac_date&after=2016-12-23T00:00:00&filter[date_query[
   column]]=acf_almanac_date`
 * and it’s returning three results (should be two) where two are after the date
   listed, and the third is before the date listed.
 * Here’s how I’m registering my actions:
 *     ```
       add_action( 'init', 'register_custom_post_types', 25 );
       function register_custom_post_types() {
       	global $wp_post_types;
   
       	$post_type_name = 'almanac_entry';
       	if( isset( $wp_post_types[ $post_type_name ] ) ) {
       		$wp_post_types[$post_type_name]->show_in_rest = true;
       		$wp_post_types[$post_type_name]->rest_base = $post_type_name;
       		$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
       	}
       }
   
       add_action( 'rest_api_init', 'wp_rest_add_custom_fields' );
       function wp_rest_add_custom_fields() {
       	register_rest_field('almanac_entry', 'acf_almanac_date', array (
           'get_callback' => function($object, $field_name, $request) {
             return get_post_meta( $object[ 'id' ], 'almanac_date', true );
           },
           'update_callback' => null,
           'schema'          => null,
         ));
       }
       ```
   
 * I’m new to doing WP dev, so I may have done this wrong. I’m wondering if maybe
   it’s due to the priority not being set in `add_action`?
 * Any help is much appreciated.
    -  This reply was modified 9 years, 9 months ago by [bbabics](https://wordpress.org/support/users/bbabics/).
      Reason: trying to figure out how to format code in my post

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Get posts after a specific date’ is closed to new replies.

 * ![](https://ps.w.org/rest-api/assets/icon-256x256.png?rev=1346297)
 * [WordPress REST API (Version 2)](https://wordpress.org/plugins/rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/rest-api/reviews/)

## Tags

 * [ACF](https://wordpress.org/support/topic-tag/acf/)

 * 6 replies
 * 3 participants
 * Last reply from: [bbabics](https://wordpress.org/support/users/bbabics/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/get-posts-after-a-specific-date/#post-8410812)
 * Status: resolved