Last active
January 2, 2019 09:06
-
-
Save carlosonweb/7929b20a8c13ea806b2b785ab92ec4b1 to your computer and use it in GitHub Desktop.
Revisions
-
carlosonweb revised this gist
Jan 2, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php /** * * This works on regular post type. -
carlosonweb created this gist
Jan 2, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ /** * * This works on regular post type. * */ add_filter( 'fl_builder_loop_query_args', function( $query_args ){ $today = date( 'Y-m-d H:i:s', time() ); if ( is_page( 'display-past-events' ) && ( 'bbtest-posts-past-events' === $query_args[ 'settings' ]->id ) ) { // Meta Key comes from ACF Plugin // -------------------------------- // $query_args[ 'meta_key' ] = 'eventenddate'; // $query_args[ 'meta_value' ] = $today; // $query_args[ 'meta_compare' ] = '<'; $query_args[ 'meta_query'] = array( array( 'key' => 'eventenddate', 'value' => $today, 'type' => 'date', 'compare' => '<', ), ); } return $query_args; } ); /** * * This doesn't work on the TEC (tribe_events) Post type. * Instead, the result is always: "Sorry, we couldn't find any posts. Please try a different search." * */ add_filter( 'fl_builder_loop_query_args', function( $query_args ){ $today = date( 'Y-m-d H:i:s', time() ); if ( is_page( 'display-past-events' ) && ( 'bbtest-tec-past-events' === $query_args[ 'settings' ]->id ) ) { // $query_args[ 'meta_key' ] = '_EventEndDate'; // $query_args[ 'meta_value' ] = $today; // $query_args[ 'meta_compare' ] = '<'; $query_args[ 'meta_query'] = array( array( 'key' => '_EventEndDate', 'value' => $today, 'type' => 'date', 'compare' => '<', ), ); } return $query_args; } );