• Home
  • Archives
  • Contact Us
Tech Yard

How To Get A Featured Post Section In Wordpress Without Any Plugins

ADVERTISEMENTS

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 coz 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 . ‘/welcome.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.

Share and Enjoy:
  • Reddit
  • SphereIt
  • Spurl
  • Technorati
  • E-mail this story to a friend!
  • Live
  • Mixx
  • Print this article!
  • Propeller
  • Sphinn
  • TwitThis

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You can receive our articles for free on your email inbox, with more freeware, windows tools and blog tips. Just enter your email below:

Delivered by FeedBurner

tag Digg This! tag Stumble it! tag Add to Del.icio.us tag Netscape it! tag Google Bookmark It!
Related Posts:
  • Featured Content Gallery Plugin To Promote Your Featured Posts
  • MassivePress - Free Wordpress Magazine Style Theme
  • Weekend Wordpress Theme : SEO Green
  • Wordpress 2.5 Stable Released
  • Display Thumbnails For Excerpts On Homepage In Wordpress Without Using Custom Fields.
  • 5 Responses to: "How To Get A Featured Post Section In Wordpress Without Any Plugins"

    1. 1 Joel Thomas
      Sunday, June 22nd, 2008 at 11:44 am

      For quite sometime now, I have been wanting to do this. Now it will help me. I have bookmarked this.

    2. 2 Venkat
      Sunday, June 22nd, 2008 at 12:05 pm

      @Joel Thomas: Feels nice that It helps you.

    3. 3 Tech Updates
      Monday, June 23rd, 2008 at 3:18 pm

      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!

    4. 4 Silki
      Thursday, June 26th, 2008 at 1:11 pm

      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.

    5. 5 Venkat
      Thursday, June 26th, 2008 at 1:36 pm

      @Silki: Thanks for droping by my blog and thanks for the stumble.


    Trackbacks/Pingbacks
    Posting your Comment!


    Join in on the conversation below!

    You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



    Translate TechYard Into Your Language

    العربية Български 中文(简体) 中文(繁體)
    Hrvatski Česky Dansk Suomi
    Français Deutsch Ελληνική हिन्दी
    Italiano 日本語 한국어 Norsk
    Polski Português Română Русский
    Español Svenska    
    Subscribe to Tech Yard by Email
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Add to Technorati Favorites! Add to netvibes

    Recent Posts

    • Bechmark Your Blog Loading Time
    • Convert Your Photos Into Sketches
    • Change Default Folder Where Windows Installs Softwares
    • US Dollar Bill Aptly Suiting The Present US Economy
    • Customize Your iPod With Themes Using iPW
    • Translate WebPages From Within FireFox
    • Check Whether Your System Can Play The Game Or Not
    • Access Google Analytics On iPhone
    • Twitter Revamp In The Making
    • Create Ripple Effect Of Your Desktop Wallpaper
  • Recent Comments

    • Avinash on Bechmark Your Blog Loading Time
    • zuborg on Bechmark Your Blog Loading Time
    • firefox tricks on Chrome Tweaks : Wordpress Theme
    • tricks on US Dollar Bill Aptly Suiting The Present US Economy
    • Tech News on Display Thumbnails For Excerpts On Homepage In Wordpress Without Using Custom Fields.
  • TECH YARD Copyright © 2008 | Disclaimer & Privacy Policy | Slick Blue Theme by Kyle Eslick