Skip to content

Instantly share code, notes, and snippets.

@JPry
Last active June 8, 2016 17:33
Show Gist options
  • Save JPry/1ac5332710887810cf9dea3871807e9b to your computer and use it in GitHub Desktop.
Save JPry/1ac5332710887810cf9dea3871807e9b to your computer and use it in GitHub Desktop.
<?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();
}
@ChristopherNeetz
Copy link

Thanks, this is really useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment