Guest User

Untitled

a guest
Dec 29th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.17 KB | None | 0 0
  1. <?php
  2.  
  3. // If setting timezone when saving data, $midnight += get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
  4. $args = array(
  5.     'post_type' => array( 'page' ),
  6.     'order' => 'DESC',
  7.     'orderby' => 'meta_value_num', // Numeric sort.
  8.     'meta_query' => array(
  9.         array(
  10.             'key' => '_cmb2_live_start_test_datetime_timestamp',
  11.             'compare' => '<=',
  12.             'value' => time(),
  13.         ),
  14.         array(
  15.             'key' => '_cmb2_live_end_test_datetime_timestamp',
  16.             'compare' => '>=',
  17.             'vaule' => time(),
  18.         ),
  19.     ),
  20.     'posts_per_page' => 1,
  21. );
  22.  
  23. $listen_query = new WP_Query( $args );
  24. ?>
  25.  
  26. <?php if( $listen_query->have_posts() ): ?>
  27.  
  28.   <?php while ( $listen_query->have_posts() ) : $listen_query->the_post(); ?>
  29.     <?php
  30.     if ( ( time() > get_post_meta( get_the_ID(), '_cmb2_live_start_test_datetime_timestamp', true ) && ( time() < get_post_meta( get_the_ID(), '_cmb2_live_end_test_datetime_timestamp', true ) ) { ?>
  31.       <a href="#"><span class="fa fa-microphone"></span><span class="listen">Live Broadcast!</span></a>
  32.     <?php } ?>
  33.  
  34.   <?php endwhile; ?>
  35.  
  36. <?php endif; ?>
  37.  
  38. <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment