How you are displaying your post in the homepage of your Blog? Probably the answer is either “Full Post” or “Excerpt”. But what if you want some post to show excerpt and some full?
WordPress don’t have any built in option to let you do this. Disappointed? Don’t be.
The following little hack will let you show some post excerpt and some full.
Hack:
Open up your index.php and look for the loop. Then replace the loop 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;
?>
Remember, this code shows post excerpt by default. To show full post in homepage, you need to create a custom field. Name the custom field full and give any value. That’s all.
Credit goes to WpRecipes.
Related posts:
- How to: Display Thumbnail Recent Posts in WordPress Related posts are very useful for both your readers...
- WordPress Tutorial: Add Social icons to every post without using plugin We all know the importance of social networks in...
- How to: Display Adsense ads only to search engine visitors When you read the title of this post, the...
- Create a Facebook Share Button for your WordPress Every time you want to increase your traffic you...
- Tweet your latest post automatically when you publish! Now a days who is not aware of twitter?...




Share




{ 2 trackbacks }
{ 0 comments… add one now }