How to: Manually define to show full post or excerpt on your homepage

January 23, 2009 at 8:30 am

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 
         } else {
              // No custom field set, let's display an excerpt

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.