Advertisement
JeffEgg

Code Help: New Loop to pull posts from category

Feb 7th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2.                 global $post;
  3.                 $args = array(
  4.                               'category_name' => 'movies',
  5.                               'posts_per_page' => '3',
  6.                               'meta_key' => 'post_expiration',
  7.                               'orderby' => 'meta_value',
  8.                               'order' => 'ASC',
  9.                               );
  10.                 $the_query = new WP_Query( $args );
  11.                 while ( $the_query->have_posts() ) : $the_query->the_post();
  12.                 $expirationtime = get_post_custom_values('post_expiration');
  13.                 $featured_event_info = get_post_meta($post->ID, 'date_range', true);
  14.                 $featured_event_title = get_post_meta($post->ID, 'short_title', true);
  15.                 if (is_array($expirationtime)) {
  16.                          $expirestring = implode($expirationtime);
  17.                      }
  18.            
  19.                      $secondsbetween = strtotime($expirestring)-time();
  20.                      if ( $secondsbetween > 0 ) { ?>
  21.                 <div class="featured-events-post">
  22.                     <a title='<?php echo $featured_event_title; ?>' href='<?php the_permalink() ?>' rel='bookmark'>
  23.                     <div class="featured-events-title"><?php echo $featured_event_title; ?></div>
  24.                     <div class="featured-events-shortdata"><?php echo $featured_event_info; ?></div></a>
  25.                 </div>             
  26.                 <?php } endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement