Brand New Featured Section
Several of my readers have asked how I created the “Featured Articles” section you see in the sidebar. To avoid repeatedly answering the same question, I’ll now be able to point them to this post.
Creating a Featured Articles section for your WordPress blog involves 3 basic steps:
- Create a new category called Featured.
- Place the code (provided below) into sidebar.php.
- Style the Featured section to match the rest of your sidebar.
Featured Articles code
Place the following code in the preferred location of your sidebar—or anywhere else you may want to display your Featured Articles:
<ul>
<?php query_posts('category_name=Featured&showposts=5'); while (have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
</li>
<?php endwhile; ?>
</ul>
Code explained
The query_posts function queries the database for all posts in the Featured category and selects the 5 latest posts. Change the 5 to whatever number you want.
query_posts('category_name=Featured&showposts=5');
This portion displays the 5 selected posts, in list format, via Post Title:
<li> <a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a> </li>
Styling your Featured Articles section
Enclose your Featured Articles section in a DIV <div id=”featured”></div> and define it in your style sheet.
#featured ul li a, #featured ul li a:visited {
/* preferred styling here */
}
#featured ul li a:hover {
/* preferred styling here */
}
Now, posts in the Featured category will be displayed in the Featured section.
This process can be applied to any section you may wish to create, anywhere on your blog. If you don’t have a Featured Articles/Posts section yet, give it a try.
Do you have any other ideas where this might be useful? Or maybe you’ve done this already to create a unique section on your blog? Tell us about it.

