Created
August 11, 2012 17:55
-
-
Save jamesmorrison/3325984 to your computer and use it in GitHub Desktop.
Custom WordPress Loop
This file contains 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
<?php | |
$custom_args = array( | |
// Declare your parameters. For example: | |
'post_type' => 'post', | |
'posts_per_page' => '4', | |
'orderby' => 'date', | |
'order' => 'DESC' | |
); | |
global $more; // Declare global $more (before the loop). | |
$custom_loop = new WP_Query($custom_args); | |
if ( $custom_loop->have_posts() ) : while ( $custom_loop->have_posts() ) : $custom_loop->the_post(); | |
?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> | |
<?php | |
$more = 0; // Set (inside the loop) to display content above the more tag. | |
the_content("Continue Reading…"); | |
?> | |
</article> | |
<?php | |
} | |
endwhile; | |
endif; | |
// reset the query | |
wp_reset_query(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment