I like to use this code to display the first full entry and then the rest of my entries as excerpts from my main page. This is not hard to do and only requires that you replace a few code snippets. You can apply this to your theme’s index template file (most commonly index.php), or whatever your blog template file may be called.
Look for the following code in the loop in your:
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?>
Replace with the following.
<?php if (have_posts()) : ?> <?php $postcount = 0; // Initialize the post counter ?> <?php while (have_posts()) : the_post(); //start the loop ?> <?php $postcount++; //add 1 to the post counter ?>
This code allows your blog to see how many posts you have.
2. Look for the following code. You are going to be replacing the_content
<?php the_content('Read the rest of this entry »'); ?>
with:
<?php if ($postcount == 1) : // if this is the first post ?> <?php the_content('Read the rest of this article ->'); //Show the full post ?> <?php else : //if this is NOT the first post ?> <?php the_excerpt(); ?> <?php endif; //end of the check for first post - other posts?>
The code basically tells your blog to show the first as the full entry and the following posts as excerpts.
Anonymous says
wow this article is very nice. It’s a new inspiration for me. i like it. thank you my friend. merry christmas and happy new year.
Jon Anscher says
Nice! Clever idea. I’m going to have to mess around with my website to see if I can get that worked out :-).
john says
What code would you use to have a footer link on all of your pages and not just your home page? Ive been messing with it for awhile and cannot figure it out. Any help would be appreciated.
benji grenier says
Great post. I will look forward to more 🙂
Khriscia says
Hi…I am really happy because I have found the post you have for us..Now I am more familiar with this post…Thanks a lot!!
Fred says
I practising web designing before and this time I will look forward for this code. Its been a long period of time that I use Notepad++ for my website.
matt says
Nile, that is something I want to do with my site since I am encountering page load time problem but I am afraid to do it on my blog coz I’m not really techie. I would suggest you create a plugin for that for sure a lot of webmaster would really be interested in customizing their homepage.
Shameka Hennagir says
That is exactly what I’m trying to do yesterday and I can’t go through because I can’t get the exact code of PHP. Thanks for this code I better yet try this one.
vishvast says
hello
thnx for this post very inpirational for me i m going to share it with my frnds also nice featured article
Monica says
Thanks for explaining the code step by step .. your blog is great help and keep us posted. Happy blogging thanks again !
Elvis Shrestha says
Hey there this is a wonderful post and your blog has got a good collection of resourceful articles… Nice blog design, your blog looks blondish… 🙂
Darryl burgess says
Nile your knowledge with word press is great. Being a novice of sort I appreciate all of your insight. Thanks for the great post once again. I look forward to future posts.
Jamie Hollister says
Knowing how to edit a little code with wordpress is extremely helpful, thanks for the great tip.
krishna says
Nice post wish u a very happy new year
Fred Martin says
very good stuff. Its also very beneficial for me as well as for visitors also. I want to do the same for my bloggspot. is there any replacing code to do that? I was trying but not succeed.
Peter says
Thanks for sharing this really great tutorial. I really like wordpress and always want tot improve more and know more about it. Thanks!
David says
I honestly not good in WordPress, i will try this to my site to make a little change.
thanks for the tips!
aufa says
I don’t dare change my WordPress code. I’ve tried, and everything is so messy. Now I use a theme that has been customized. But this article is good enough to learn. Thank you 🙂
Steve Borgman says
Nile, thank you for this handy tip! I’m going to bookmark this article and put it in my To Do list to improve my sites. Thanks for all you do!
Jacko says
Thanks for the tip.
I recommend you use a subscription service to build your email list and send out notices no more than once a week.
Cynthia says
Ahhh, what a relief to see someone who likes technical, “geeky” (no offense intended) stuff just like I do. 🙂 Thanks, I will be looking for more tips in your site.
Nathalie Villeneuve says
Nile, thank you for this great tip! You have the best stuff to help us make improvements and gain more knowledge about blogging and being more efficient
Perry A Davis Jr says
Hello Niles
It seems that excerpts, especially in search results, helps the reader get to the information they need faster, making them happier readers. Currently I display one full article and two excerpts on my blog. What do you think about only displaying excerpts?
Thanks
Perry A Davis Jr
Music City
Manuel Marino says
very good ideas, absolutely.
I solve in another way, creating sticky posts (static pages) to attract visitors attention to the best articles I’ve got.
And I change them from time to time.
Anonymous says
Great I will try this on my wordpress blog, but can you do this for blogger as well?
Donna Merrill says
Just wanted to say that you are doing such a great job on your blog. This post in particular is a challenge for me – but reading it twice did finally get into my head. I have a word press blog and need to start doing things myself. It is a Giant learning curve for me because I’m all tumbs when it comes to this. But please keep your information coming. I’m enjoying your posts.
Donna
Yorinda says
Thank you, Nile, for the informative article.
Coding fascinates me, so much we can do with it!
The Suffusion Theme for WordPress has lots of options to set excerpts for you posts,categories and even tags.
Great to have information from an experienced Webmaster!
kristeen says
SuperB article. Love the way you set-up the article. Its really good writen, thanks!
Eddie Gear says
while I appreciate you dealing out the process and helpful tutorial, Here is one advice on SEO, do no display full post in multiple locations, as they are considered as duplicate content. Imagine a crawler fetching the homepage with the full content post and also the single page url. Now its seen two different urls with the same content.
Monica says
Thanks for the explanations. You have a unique way of explaining the code
Chris says
Code fascinates me. I’m just glad there are some smart folks out there that can figure this type of thing out for the rest of us. Thanks for sharing!!
Edyta says
Hi Nile,
Thanks for sharing very interesting tips. I didn’t realise that it is so easy. I would like to know how to create slide show that you have on your home page. Please give me some tips. Thanks.
alicia says
I enjoy navigating in your website, it is easy to find my topics of interest. Thanks so much for the tip; I will work on it to apply it on my blog.
Doug Gene says
Thanks for the helpful codes, Nile. Know of any other code resources for WordPress?
rohit kothari says
just one word for this thanks i was looking for the solution(coding) of making full entry and found this on your site so good luck create such wonderful post in future too
Stevie says
That’s really a cool trick. That’s the beauty of open source though isn’t it. The ability to fine tune to one’s heart content!
Kevin Martineau says
Thanks for sharing how to do this Nile! This is awesome. I am going to give it a try.
Kevin
Paul Reimers says
Cool trick,
I always like to see a number of posts in excerpt form to make it easy to choose from, but this approach is excellent in that it naturally gives more weight to the most recent post.
Vernon says
Thanks for sharing the codes and explaining how to use it directly. I will try it right away. More thanks.
clare says
Hi Nile,
Thanks for this great tip! Just what I wanted to learn about. I have become more confident in applying code to my blog. I don’t like seeing the full articles displayed. I am bookmarking your site so i can come back to this when I get to this point on my week’s to-do list! Also, I assume that adding code is more efficient that using plug-ins which slow the site loading time?
Best regards,
Clare
Coach James says
Interesting idea. I haven’t ever wanted to have a full post on my blog page, but I wonder if this helps keep people focused and on your site longer as it present the post and the reader doesn’t have to click….
Hmmm. Will give some thought to this.
Thanks,
James
sadie-Michaela Harris says
Hello Nile Happy New Year, I have a growing list of tasks to make my site function better and thanks for all your tips, I appreciate you 🙂
Sharilyn says
Now I get a lot of ideas from this post…I am really thankful or this!!Thanks a lot then!!
cat says
Hi, I’m using the Pagelines theme and that code I could not locate in the index template to make changes. Any ideas? I’d like to make my posts actually all longer (all of them on home page) not just the first one – they said I’d need to change the WordPress coding – but next best thing would be for the first one to be longer.
Thank you!
Jeffrey T. Sooey says
Thanks Nile. Thanks for the tip. These codes will help me in my blog entries. Can’t wait to try it out on my next blog.
Jeziel says
This is a big help to me and for all the people who will read this then…Thanks for the great post and this is a big help too…
masita says
Thank you for your tips. I use a theme that is easy to use. I’m afraid to change the existing standard script, because I have a bad experience about it. but finally I find out a little way about how to edit the blog script from this blog 🙂
Peter says
Thanks for sharing very interesting tips. I didn’t realise that it is so easy. I would like to know how to create slide show that you have on your home page. Please give me some tips. Thanks.
Nile says
I am actually using a WordPress plugin for my slider. It is a premium one, but the free version is in the WordPress directory and called Easing Slider.
jobin says
your blog is great help and keep us posted. I have become more confident in applying code to my blog…..
http://www.findghar.com
Navin kunwar says
i use plugin to display the excerpts but using the code in theme is great way to reduce server load. thanks
sai krishna says
i’m looking for this tutorial from so many of days , finally i found it . Thank you for the tutorial , nice share 🙂
matt says
Hi Nile, its me again. I just want to ask if how can I just display excerpts on home page instead of full entry of first post.
Nile says
In your template, instead of the_content call, you want to put the_excerpt.
matt says
Hi Nile, yes, is it possible? I’ve change the_content to the_excerpt on page template but nothing happens. May I know what particular template to edit. I am using wordpress theme coraline. Thanks.
Mohana says
WOW! What a simple, highly useful tutorial! Thanks for this great help!