Created
December 20, 2024 13:19
-
-
Save Pross/4f12d6cbfba52f53b02a3d15cf536564 to your computer and use it in GitHub Desktop.
Preserve BB loop meta_query when using events
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
add_filter( 'fl_builder_loop_query_args', function( $args ) { | |
global $bb_meta; | |
$bb_meta = $args['meta_query']; | |
return $args; | |
}); | |
add_action( 'pre_get_posts', function( $query ) { | |
if ( $query instanceof WP_Query && isset( $query->query['fl_builder_loop'] ) ) { | |
global $bb_meta; | |
$meta = array(); | |
$meta[] = $query->get( 'meta_query' ); | |
$meta[] = $bb_meta; | |
$query->set( 'meta_query', $meta ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment