How To Create A Featured Post Section In WordPress Without Any Plugins
You can see that I have recently changed my theme and also included a Featured Post Section, It took a lot of time for me to get it working because of my little knowledge in PHP but with some trial and error I was able get it working.
I’ll show you how to get your featured Post section in your blog.So lets get started
STEP 1 : Create a Category “Featured” for your blog.
STEP 2 : Create a file “featured.php” in the theme folder.
<?php $my_query = new WP_Query(‘category_name=Featured&showposts=1′);
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<div id=”feature”>
<img src=”replace with featured post image.jpg“></img>
<h2 class=”post-title”>
<a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a>
</h2>
<?php the_excerpt(); ?>
<?php edit_post_link(__(‘Edit’), ”, ‘ | ‘); ?>
<?php comments_popup_link(__(‘No Comments’), __(’1 Comment’), __(‘% Comments’)); ?> | <a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php _e(‘Read full story »’); ?></a>
</div>
<?php endwhile; ?>
STEP 3 : Open ” index.php ”
Generally the first line would be the get_header(), if you want your Featured Post Section be right after the header , place this line right after that
<?php include (TEMPLATEPATH . ‘/featured.php’); ?>
STEP 4 : Find this line
<?php while (have_posts()) : the_post();?>
in the same index.php and place this next line right after the above line
<?php if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
This does not allow the post to repeat itself in the regular posts below the featured posts thereby eliminating duplicates.
STEP 5: A bit of CSS , add this in your style.css
#feature{
width: 800px;
height: 132px;
float: left;
padding:20px 20px 20px 20px;
font-size:12px;
line-height:16px;
}
#feature img {
float: right; margin: 3px 5px 10px 0; backgroundr:#FFFFFF;
}
Hope this helps you get the Featured Posts up and running in your blog.
Another thing is that for the excerpt to be clean you need to explicitly give an excerpt to the Excerpt Block in your WordPress Advanced Options in the Write Post Admin . The excerpt that you give in the excerpt is displayed on the Homepage.
NOTE : For the Featured post to work you need at least 1 post in your Featured Category.

Joel Thomas
Jun 22, 2008 @ 11:44:29
For quite sometime now, I have been wanting to do this. Now it will help me. I have bookmarked this.
Venkat
Jun 22, 2008 @ 12:05:15
@Joel Thomas: Feels nice that It helps you.
Tech Updates
Jun 23, 2008 @ 15:18:12
Wow this is just awesome
I will give a try for this one asap on my blog. Will need to take care about the coding changes i do on my theme because its already heavily customized!
Silki
Jun 26, 2008 @ 13:11:17
That is a cool application. There is a section on my theme, which shows featured post, but I never tried to understand the code behind it.
Stumbling.
Venkat
Jun 26, 2008 @ 13:36:38
@Silki: Thanks for droping by my blog and thanks for the stumble.
Iain Stubley
Oct 14, 2008 @ 01:23:56
Hey you helped me out with this one! Never knew how this could be done ..
Jonas
Jan 27, 2009 @ 22:40:27
Hi!
Great, just what I wanted.
But what if I wanted 3 or 4 different featured posts sections? Perhaps one above the usual loop and one beneath it. Do I just copy and paste the code and changing the category name?
Best regards
Jonas
Avinash
Jan 27, 2009 @ 23:02:59
Hi Jonas, you can try that out that should work.
Jonas
Jan 28, 2009 @ 14:14:41
@Avinash: Great! I´ll try that. Just worrying to crash stuff.
Avinash
Jan 28, 2009 @ 18:32:25
@Jonas you could try that on your local WP Installation before trying it on your live site.
r_shahin
Feb 22, 2009 @ 15:41:38
[...] 2. Another one by TechYard.net [...]
SS Senthil Kumar
Jun 23, 2009 @ 15:03:32
The exact post that i needed. Thanks Dude!
WebVeins
Jul 07, 2010 @ 18:48:15
I want the plugin to fetch the image from the post automatically.
and at least five featured post must be there on the page.
can you help me please.
Thanks
Shawn
Aug 03, 2010 @ 08:15:32
shouldn’t it be featured.php instead of welcome.php on TEMPLATEPATH thing?
Avinash
Aug 03, 2010 @ 16:28:52
Your right Shawn, it should be featured.php thanks again.I’ve also corrected the post to the same.
sanjaya
May 21, 2011 @ 10:27:39
Thanks for ur tutorial before
But i got error message:
Warning: include(C:\xampp\htdocs\wordpress-edit\wordpress/wp-content/themes/Digital Statement?featuredphp?) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\wordpress-edit\wordpress\wp-content\themes\Digital Statement\index.php on line 2
And…
Warning: include() [function.include]: Failed opening ‘C:\xampp\htdocs\wordpress-edit\wordpress/wp-content/themes/Digital Statement?featuredphp?’ for inclusion (include_path=’.;C:\xampp\php\pear\’) in C:\xampp\htdocs\wordpress-edit\wordpress\wp-content\themes\Digital Statement\index.php on line 2
So what’s the solution of the error messages?
Thx so much..
Avinash
May 21, 2011 @ 14:28:32
Hi Sanjaya, make sure you have pear installed in xampp.., try opening php.ini file which you can find in the XAMPP Folder and look for inclide_path for PEAR in the Paths and Directories Section which should be pointing towards the pear folder .. check out this http://www.apachefriends.org/f/viewtopic.php?f=16&t=32213&start=0&view=print for some more help ..
Hittesh Ahuja
Jun 12, 2011 @ 01:44:15
I dont think you have its still showing welcome.php
Avinash
Jun 12, 2011 @ 14:43:13
Thanks for the headsup.. I edited the post .. you can check it now..
Niraj
Jul 14, 2011 @ 16:34:00
Hey nice tutorial to display featured posts, I just found featured post tutorial, its like a news vertical ticker,
just check out
http://webstutorial.com/wordpress-make-featured-post-jquery-ticker-wordpress-make-featured-posts/content-management-system-cms
This featured post can show either title or title with excerpt