Advertisement
DidouS

20221117-DS-Beaver Builder filter posts future date custom field

Nov 17th, 2022
1,350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. // Add a Post Module, got to Advanced Tab and set the ID to 'example-module'.
  2. // Or to whatever you will use in the callback below
  3. //
  4. // It assumes that on the post type and posts there is a field called 'my_until_field',
  5. // which will be used to further filter the query results
  6.  
  7. function fl_builder_loop_query_args_filter( $query_args ) {
  8.     if ( 'example-module' == $query_args['settings']->id ) {
  9.       $query_args['meta_query'] = array(
  10.         'relation' => 'AND',
  11.         'my_until_field_clause' => array(
  12.             'key' => 'my_until_field',
  13.             'value' => date( 'Ymd' ),
  14.             'compare' => '>=',
  15.             'type' => 'DATE',
  16.         )
  17.        );
  18.     }
  19.     return $query_args;
  20.   }
  21.  
  22.   add_filter( 'fl_builder_loop_query_args', 'fl_builder_loop_query_args_filter' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement