date_query_valid_columns

Filters the list of valid date query columns.

Description

apply_filters( 'date_query_valid_columns', (array) $valid_columns ); 

Parameters (1)

0. $valid_columns (array)
An array of valid date query columns. Defaults are post_date,, post_date_gmt, post_modified, post_modified_gmt, comment_date, comment_date_gmt, user_registered

Usage

To run the hook, copy the example below.
  1. $valid_columns = apply_filters( 'date_query_valid_columns', $valid_columns ); 
  2.  
  3. if ( !empty( $valid_columns ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the date_query_valid_columns callback 
  2. function filter_date_query_valid_columns( $valid_columns ) { 
  3. // make filter magic happen here... 
  4. return $valid_columns
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'date_query_valid_columns', 'filter_date_query_valid_columns', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'date_query_valid_columns', 'filter_date_query_valid_columns', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/date.php  
  1. if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) {