Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. $expire = get_field('status_time_duration') + get_the_time('U'); // UNIX time that gets the publish date plus an additional time in seconds
  2.  
  3. function alerts_opby( $qvars ){ //function to call up the query
  4. $qvars[] = 'opby_alerts';
  5. return $qvars;
  6. }
  7. add_filter( 'query_vars', 'alerts_opby' );
  8.  
  9. function opby_query( $query ) { //pre_get_posts functions
  10. if (isset( $query->$qvars['opby_alerts'] )) {
  11. $expire = get_field('status_time_duration') + get_the_time('U');
  12. $current = date( 'U', current_time( 'timestamp', 0 ) );
  13. $query->set('tax_query', array(array('taxonomy' => 'post_format','field' => 'slug','terms' => array( 'post-format-status' ),'operator'=> 'IN'),
  14. ),'meta_query', [
  15. 'relation' => 'OR',
  16. [
  17. 'key' => 'status_time_duration',
  18. 'value' => $expire,
  19. 'compare' => '<=',
  20. 'type' => 'NUMERIC',
  21. ],
  22. [
  23. 'key' => 'status_time_duration',
  24. 'compare' => 'NOT EXISTS',
  25. ],
  26. ],
  27. $query->set('posts_per_page', -1));
  28. }
  29. return $query;
  30. }
  31. add_action( 'pre_get_posts', 'opby_query' );
  32.  
  33. $expire = get_field( 'status_time_duration' ) + get_the_time( 'U' );
  34.  
  35. 'meta_query', [
  36. 'relation' => 'OR',
  37. [
  38. 'key' => 'status_time_duration',
  39. 'value' => date( 'U' ),
  40. 'compare' => '<=',
  41. 'type' => 'NUMERIC',
  42. ],
  43. [
  44. 'key' => 'status_time_duration',
  45. 'compare' => 'NOT EXISTS',
  46. ],
  47. ],
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement