jlittlejohn
9/11/2012 - 11:15 PM

WP: Loop with get_posts()

WP: Loop with get_posts()

<!-- Used to get an array of posts -->
<?php global $post; // required
  $args = array(
    'posts_per_page'  => 5,
    'numberposts'     => 5,
    'offset'          => 0,
    'category'        => '',
    'orderby'         => 'post_date',
    'order'           => 'DESC',
    'include'         => '',
    'exclude'         => '',
    'meta_key'        => '',
    'meta_value'      => '',
    'post_type'       => 'post',
    'post_mime_type'  => '',
    'post_parent'     => '',
    'post_status'     => 'publish',
    'suppress_filters' => true 
  ); // Default arguments
  $custom_posts = get_posts($args);
  
  foreach($custom_posts as $post) : setup_postdata($post); ?>
    <!-- code -->
  <?php endforeach; ?>
?>