cannot filter after using pre_get_posts


I am using pre_get_posts() in the backend for a custom post type screen where all the records are usually displayed.

The action I have is showing only posts for today’s date. This is working fine but when I try to use the default filter for different dates I get no data even though I know there is data. (removing the action shows all the data).

Is there a way I can use pre_get_posts but still filter/show previous dates?

add_action ( 'pre_get_posts',  'modify_query_get_apps_by_date' );

function modify_query_get_apps_by_date( $query ) {

    if ( is_admin() && $query->is_main_query() && $query->get( 'post_type' ) == 'apps' ) {
          $query->set( 'meta_query', [
                  'key' => 'app_date',
                  'value' => date('d-m-Y'),
, user10980228 8 months 0 Answers 60 views 0

Leave an answer