Last active
January 2, 2019 09:06
-
-
Save carlosonweb/7929b20a8c13ea806b2b785ab92ec4b1 to your computer and use it in GitHub Desktop.
TEC vs Post "fl_builder_loop_query_args" Filter Hook
This file contains 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 characters
<?php | |
/** | |
* | |
* 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; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment