Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $expire = get_field('status_time_duration') + get_the_time('U'); // UNIX time that gets the publish date plus an additional time in seconds
- function alerts_opby( $qvars ){ //function to call up the query
- $qvars[] = 'opby_alerts';
- return $qvars;
- }
- add_filter( 'query_vars', 'alerts_opby' );
- function opby_query( $query ) { //pre_get_posts functions
- if (isset( $query->$qvars['opby_alerts'] )) {
- $expire = get_field('status_time_duration') + get_the_time('U');
- $current = date( 'U', current_time( 'timestamp', 0 ) );
- $query->set('tax_query', array(array('taxonomy' => 'post_format','field' => 'slug','terms' => array( 'post-format-status' ),'operator'=> 'IN'),
- ),'meta_query', [
- 'relation' => 'OR',
- [
- 'key' => 'status_time_duration',
- 'value' => $expire,
- 'compare' => '<=',
- 'type' => 'NUMERIC',
- ],
- [
- 'key' => 'status_time_duration',
- 'compare' => 'NOT EXISTS',
- ],
- ],
- $query->set('posts_per_page', -1));
- }
- return $query;
- }
- add_action( 'pre_get_posts', 'opby_query' );
- $expire = get_field( 'status_time_duration' ) + get_the_time( 'U' );
- 'meta_query', [
- 'relation' => 'OR',
- [
- 'key' => 'status_time_duration',
- 'value' => date( 'U' ),
- 'compare' => '<=',
- 'type' => 'NUMERIC',
- ],
- [
- 'key' => 'status_time_duration',
- 'compare' => 'NOT EXISTS',
- ],
- ],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement