Title: date_query with select options
Last modified: August 22, 2016

---

# date_query with select options

 *  [ner0tik](https://wordpress.org/support/users/ner0tik/)
 * (@ner0tik)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/date_query-with-select-options/)
 * I’m trying to modify the plugin Genesis Sandbox Featured Content Widget
    so that
   it uses date_query when querying posts. the code I’ve got is
 *     ```
       'date_query'             => array(
       			'label'       => __( 'Date Range', 'gsfc' ),
                       'description' => 'show posts made before or after a selected time frame',
                       'type'        => 'select',
                       'options'     => array(
       			''      => __( 'Select', 'gsfc' ),
   
                   'after' => '1 day ago',  __( 'After 1 day ago', 'gsfc' ),
                   'after' => '1 week ago', __( 'After 1 week ago', 'gsfc' ),
       			'after' => '1 month ago', __( 'After 1 month ago', 'gsfc' ),
       			'after' => '1 year ago' , __( 'After 1 year ago', 'gsfc' ),
       			'before' => '1 day ago', __( 'Before 1 day ago', 'gsfc' ),
       			'before' => '1 week ago', __( 'Before 1 week ago', 'gsfc' ),
       			'before' => '1 month ago', __( 'Before 1 month', 'gsfc' ),
       			'before' => '1 year ago',  __( 'Before 1 year ago', 'gsfc' ),
   
       			),
       			),
       ```
   
 * I’m using print_r to show how the query is being run and its output is:
    Array([
   post_type] => post [posts_per_page] => 5 [orderby] => date [order] => ASC [date_query]
   => 1 [meta_key] => [paged] => )
 * as i switch between date ranges it will return [date_query] => 2, [date_query]
   => 3 etc.. I don’t know why its not working.
 * here is a screenshot of the form on the admin side, which is also not displaying
   correctly. [http://s17.postimg.org/asf1pjhmn/daterange.jpg](http://s17.postimg.org/asf1pjhmn/daterange.jpg)
   
   its displaying two extra ‘1 year ago’ text.
 * I’ve tried searching for similar examples to see what I’m doing wrong but i can’t
   find anything. any help is greatly appreciated.

The topic ‘date_query with select options’ is closed to new replies.

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [ner0tik](https://wordpress.org/support/users/ner0tik/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/date_query-with-select-options/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
