Created
September 11, 2012 23:15
-
-
Save jlittlejohn/3702914 to your computer and use it in GitHub Desktop.
WP: Loop with get_posts()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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; ?> | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment