Slider Revolution WP
09.06.2016
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// code can be added to your themes functions.php file add_filter('essgrid_query_caching', 'eg_stop_caching', 10, 2); add_filter('essgrid_get_posts', 'eg_mod_query', 10, 2); // turn off caching for your grid function eg_stop_caching($do_cache, $grid_id) { if($grid_id == YOUR_GRID_ID) return false; return true; } function eg_mod_query($query, $grid_id){ if($grid_id == YOUR_GRID_ID) { //modify $query to your likings } return $query; } |
In the following example, where posts represent “events” that have a start and end date, we could use the filter to only show events from the past, or even better, only show events that are scheduled to happen in the future.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
// code can be added to your themes functions.php file add_filter('essgrid_query_caching', 'eg_stop_caching', 10, 2); add_filter('essgrid_get_posts', 'eg_mod_query', 10, 2); // turn off caching for your grid function eg_stop_caching($do_cache, $grid_id) { if($grid_id == YOUR_GRID_ID) return false; return true; } function eg_mod_query($query, $grid_id){ // show only upcoming events in the future if($grid_id == 36){ $query['meta_query'] = array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '>=', 'type'=>'numeric' ); $query['meta_key'] = '_start_ts'; $query['meta_value'] = current_time('timestamp'); $query['meta_value_num'] = current_time('timestamp'); $query['meta_compare'] = '>='; } // show only events from the past if($grid_id == 50){ $query['meta_query'] = array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '<=', 'type'=>'numeric' ); $query['meta_key'] = '_start_ts'; $query['meta_value'] = current_time('timestamp'); $query['meta_value_num'] = current_time('timestamp'); $query['meta_compare'] = '<='; } return $query; } |