DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Do you use excerpts or full posts on your blog excerpts? Personnally, I think they’re both good. The only problem is that you can’t, by default, use both excerpts and full posts on your blog homepage. Here’s a code to do it.

On your index.php file, replace your current loop by this one:

<?php if (have_posts()) :
    while (have_posts()) : the_post();
         $customField = get_post_custom_values("full");
       	 if (isset($customField[0])) {
              //Custom field is set, display a full post 
              the_title();
              the_content();
         } else {
              // No custom field set, let's display an excerpt
              the_title();
              the_excerpt();
    endwhile;
endif;
?>

On the code above, the default is excerpts. When you want to show a full post on your blog homepage, simply edit the post and create a custom field named full and give it any value.

One Comment

  1. This is very helpfull but there is a missing bracket after the “the_excerpt();” function and before the “endwhile;”

Leave a Comment

Your email address will not be published. Required fields are marked *