How Blog Posts Are Displayed On The Home Page In WordPress
97% of bloggers displays all of their posts the same way on their home page. Sure, WordPress has no built-in option to let we define how a post displayed.But wait: with custom fields,we can do it easily.
Define how a post is displayed on our home page.
Two values are possible:
• Full post
• Post excerpt only
Once more, we’ll use a custom WordPress loop. Find the loop in our
index.php file and replace it with the following code:
<?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;
?>
In this code, excerpts are displayed by default. To show full posts on our
home page, simply edit the post and create a custom field called full and
give it any value.
Total Page Visits: 6596 - Today Page Visits: 4