Advertisement
alchymyth

today-or-future query

Sep 1st, 2011
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2.         $args=array(
  3.       'post_type' => 'familygames',
  4.           'post_status' => 'publish',
  5.           'order' => 'ASC',
  6.           'orderby' => 'menu_order',
  7.           'posts_per_page' => 1,
  8.           'caller_get_posts'=> 1,
  9.           'year' => date('Y'),
  10.       'monthnum' => date('n'),
  11.       'day' => date('j'),
  12.     );
  13.         $my_query = null;
  14.         $my_query = new WP_Query($args);
  15.        
  16.         if( !$my_query->have_posts() ) {
  17.     $args=array(
  18.       'post_type' => 'familygames',
  19.           'post_status' => 'future',
  20.       'order' => 'ASC',
  21.           'orderby' => 'date',
  22.           'posts_per_page' => 1,
  23.           'caller_get_posts'=> 1,
  24.         );
  25.         $my_query = null;
  26.         $my_query = new WP_Query($args); }
  27.        
  28.         if( $my_query->have_posts() ) {
  29.           while ($my_query->have_posts()) : $my_query->the_post(); ?>
  30.            
  31.             <li><span><a href="<?php the_permalink(); ?>"><strong><?php the_title(); ?></strong></a></span></li>
  32.            
  33.         <?php
  34.       endwhile;
  35.     } else { echo 'not today Zurg'; }
  36.     wp_reset_query();
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement