A WordPress featured post section allows you to display your best content right on the home page where it’s most visible. While many premium themes include similar elements, they aren’t as functional as a featured post section.
Sure, you can always use the old standby of the “sticky post” operation to keep an entry at the top of a featured post section, but it won’t truly work as well. Using a WordPress featured post section keeps your best article at the top of the heap while still showing newer posts under it.
Why Use a WordPress Featured Post Section
Making a post sticky is a quick fix, but it only works for one particular post. Remove the sticky attribute and that post falls back in line. A featured post section will work in a more fluid, useful way than any other shortcut or trick.
The biggest problem in implementing a WordPress featured post section is that many step-by-step tutorials don’t address pagination. In other words, insert a featured post section and the “previous” and “next” links at the bottom of the page. But here’s a WordPress featured post section workaround that won’t break pagination.
How to Implement a Featured Post Section
Let’s start with the categories. Go into your dashboard and create a new category. You can name it anything you’d like, but for this lesson, we’ll name it “Featured”. Once that’s in place, move on to the code:
1) Create a loop for the platform of your featured post section using this code:
$limit = get_option(‘posts_per_page’);
query_posts(‘showposts=’ . $limit . ‘&paged=’ . $paged .’&cat=-5′); ?>
< ?php if (have_posts()) : ?>< ?php while (have_posts()) : the_post(); ?>
/*** insert custom code here ***/
< ?php endwhile; endif; ?>
2) Replace the “cat=-5” with the number corresponding to your new featured category.
<?php query_posts(‘posts_per_page=1&cat=-5’); ?>
3) Now, go into your editor and find the pagination code. It will look something like this:
< ?php posts_nav_link(‘ – ‘, ‘Go Forward In Time’, ‘Go Back In Time’); ?>
4) Now add the code below into the new featured.php file you just created:
< ?php endwhile; endif; ?>
5) Add this to your index.php file
< ?php if(is_home() && !is_paged()): ?>
< ?php include (TEMPLATEPATH . ‘/featured.php’); ?>
< ?php endif;?>
Basically, what we’ve done with this featured post section is create two separate, distinct loops for your WordPress site. Now, when you write a new post, you’ll have the ability to categorize it as “Featured”. When posts are assigned to this category, they will appear at the top. And all other posts created in other categories will appear below the featured post section.
If you want to learn more about the power of WordPress or have trouble setting up a featured post section, then just contact us. We’ll be happy to customize your WP site and all consultations are free!