October 1, 2022
how to create a WordPress featured post section

How to Create a WordPress Featured Post Section

Learn how to create a WordPress featured post section to update a pre-built theme or custom website for more visual appeal and quick access to top content…

With a WordPress featured post section, a website is able to display its best content right on the home page where it’s most visible. While many pay-for-play premium themes include similar elements, they aren’t as functional as a custom featured post section. Although the “sticky post” operation will keep an entry at the top of the blog or homepage, it’s not a long-term solution. Using a WordPress featured post section keeps your best article at the top while simultaneously displaying newer posts along with it.

Why Use a WordPress Featured Post Section

Designating a post as sticky is a quick fix, but it only works for one particular post. Remove the sticky attribute and the post falls right back in chronological order, on the original day and time first published. A featured post section will work in a more fluid, useful way over any other shortcut trick. 

Originally launched in 2003, WordPress has become perhaps the most popular content management system (CMS) in the world. Today, WordPress is used by more than 74 million sites that publish new posts every second. No matter the size of the blog that is using WordPress. This widely used CMS has become a favorite among businesses because of how powerful of a tool it is. —Entrepreneur.com

The biggest problem with creating a WordPress featured post section is too many step-by-step tutorials don’t address the pagination problem. In other words, the unintended impact on the “previous” and “next” blog article links at the bottom of the page. But this WordPress featured post section workaround will not break a site’s native pagination.

How to Create a WordPress 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 label it “Featured”. Once in place, move on to the code. Here’s the next steps for how to create a WordPress featured post section to update a pre-built theme or custom website for more visual appeal and quick access to top content:

  1. Create a featured post section loop using this code:

    <div class="normal_posts">
    < ?php
    $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 assigned category number with the number corresponding to the new featured category.

    <?php query_posts('posts_per_page=1&cat=-5'); ?>
  3. Now, go into the editor and find the pagination code; it will look something like this:

    <div id="post_nav">
    < ?php posts_nav_link(' - ', 'Go Forward In Time', 'Go Back In Time'); ?>
  4. Find the code that looks similar to the one below:
    < ?php endwhile; endif; ?>
  5. Now add the code below into the new featured.php file you just created:

    < ?php if(is_home() && !is_paged()): ?>
    < ?php include (TEMPLATEPATH . '/featured.php'); ?>
    < ?php endif;?>

Now, the work you’ve done creates two separate, distinct loops for your WordPress site. So, when you create a new post, you’ll have the option to set it to the “Featured” category. All posts assigned to this category will appear at the top; and, all other posts created in other categories will appear below the new featured post section.

Thanks for taking a few moments of your time to read this; if you like this post, please share it with your friends!

Owen E. Richason IV

Covers social media, apps, search, and similar news. History buff, movie, and theme park lover. Blessed dad and husband.     

View all posts by Owen E. Richason IV →