Display full post or just excerpt using custom fields

Adding this snippet to the loop of your wordpress theme within single.php or index.php will let you use a custom field value to define if a post is displayed in full or just the excerpt.

 

<?php if (have_posts()) :
while (have_posts()) : the_post();
$customField = get_post_custom_values("full");
if (isset($customField[0])) {
the_title();
the_content();
} else {
the_title();
the_excerpt();
endwhile;
endif;
?>

Be Sociable, Share!

Leave a comment