Last active
June 8, 2016 17:33
-
-
Save JPry/1ac5332710887810cf9dea3871807e9b to your computer and use it in GitHub Desktop.
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 | |
/** | |
* This is a sample function to illustrate your loop. | |
*/ | |
function your_function() { | |
$displayed_full_content = false; | |
$posts = new WP_Query( /* your query args here*/ ); | |
while ( $posts->have_posts() ) { | |
$posts->the_post(); | |
// For the first post, display the full content. | |
if ( ! $displayed_full_content ) { | |
the_content(); | |
$displayed_full_content = true; | |
} else { | |
the_excerpt(); | |
} | |
} | |
// When using a custom loop, it's always good practice to restore the regular post data. | |
wp_reset_postdata(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this is really useful!