Skip to content

Instantly share code, notes, and snippets.

@kadavre
Last active December 28, 2015 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadavre/7411353 to your computer and use it in GitHub Desktop.
Save kadavre/7411353 to your computer and use it in GitHub Desktop.
Majority of bloggers display posts in more or less them same way on the home pages of their blogs. This is understandable since WordPress does not feature a default option to define how posts should be displayed. Fortunately, you can surmount this problem by using custom fields. To define posts in your home page, you can use either the full post…
<?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;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment