How to use Sticky Post to add Categories in WordPress?

How to use Sticky Post to add Categories in WordPress_

Since WordPress has a plethora of different features, it is no surprise to see WordPress users missing out on some of these features especially the beginners. Out of many features of WordPress, one such feature that you may not even know available is Sticky Post.

Sticky Post is a very useful and handy WordPress feature that enables you to integrated featured posts in your websites. This amazing feature can be used to make a post stick to your website’s homepage. This feature can be used on posts and categories. By using this feature on categories, you can display a post from the selected category as a featured post. Sticky Post was first introduced in WordPress version 2.7, however, a majority of users don’t even know where to find it and how to use it.

Therefore, in this post, we are going to talk about Sticky Post and how they can be created and used on your website.

Why you need Sticky Post for your website?

If you have been working with WordPress, you’d probably know that it displays the latest posts on the homepage in a reverse chronological order. However, there are times when you need to display some of the posts on the top of the other posts. This is where Sticky post feature comes into play. All you need to do is mark the posts, which you want to display at the top of your homepage, as sticky.

Why you need Sticky Post for your website_

However, if you want to remove this feature from your posts, you will have to either do it manually or put an expiration date with the help of a plugin called Expire Sticky post.

How to create a sticky post to add categories in your WordPress powered website?

Install Category Sticky Post plugin

As a matter of fact, WordPress offers an assortment of plugins to extend the functionality of your website and Sticky Post for categories is no different. There is a very easy to use WordPress plugin available known as Category Sticky Post developed by Tom McFarlin.

Though the plugin functions exactly same as that of a sticky feature in WordPress, it creates a sticky and featured post for your post categories. Category Sticky Post is an extremely useful plugin especially if you are looking to display a particular post from a particular category on the top of the category archive.

Additional features of Category Sticky Post:

• Enables you to choose a category in which to stick a post
• Will automatically show the post on the top of the homepage of the archive merely like inbuilt sticky post feature
• Allows you to stick only a single post under one category
• Notifies you whether or not the post is stuck in a category archive on the Post Edit Dashboard
• Offers light and simple styling that looks good in many themes
• Comes equipped on each post editor page
• Completely ready for translation and fully localized
• Also has Spanish translations

Install Category Sticky Post plugin

The first thing you would need to do is to install the plugin into your WordPress website and activate it. There is no rocket science in installing and activating a plugin. Simply click plugins → add new and search for Category Sticky Post plugin in the search bar. Hit install now.
Once you have installed the plugin, activate it to use it.

The plugin, Category Sticky Post, does not have any settings page and thus no configuration is required in order to use this plugin to create a sticky post for categories.
Just edit an existing post or create a new one, and you will be allowed to add a sticky post with the help of a new option added “Category Sticky” meta box in the post edit area.

Plugin 2

Now, choose a category under which you would want to publish a post as a sticky post and hit save.

If in case you would want to publish another sticky post in the same category, you would have to uncheck the category from the sticky post you created earlier. Also, it is not necessary to make a post sticky in the same category. As an instance, a post from design category can be made sticky in the development category.

However, every category can have only one sticky post at a time and every post can only be made sticky under one category.

A default black border on the top and bottom of the sticky post is added by Category Sticky Post plugin simply to make it stand out from the other posts published on the website. But, this black border can be easily removed by checking the Hide Sticky Post Border checkbox.

When Hide Sticky Post Border checkbox is unchecked, the plugin automatically adds a category-sticky class to the category sticky post. To override this class, you can copy and paste the following code into your stylesheet.

.category-sticky {

How to display sticky post on your website?

Once you have successfully created the sticky post for your categories, it’s time to display it in different areas of your site. Lets suppose, you want to show the titles of the 3 sticky posts together with their links. For this, simply copy and paste the following lines of code into your plugin file or theme’s functions file:

/* Function to retrieve latest sticky posts */
function wpp_latest_sticky() {
/* Get all sticky posts */
$sticky = get_option( 'sticky_posts' );
/* Sort the stickies with the newest ones at the top */
rsort( $sticky );
/* Get the 3 newest stickies (change 3 for a different number) */
$sticky = array_slice( $sticky, 0, 3);
/* Query for sticky posts */
$the_query = new WP_Query( array( 'post__in' => $sticky, 'ignore_sticky_posts' => 1 ) );
if ( $the_query->have_posts() ) {
$return .= '

    while ( $the_query->have_posts() ) {
    $return .= '

  • ' . get_the_title() . '
    ' . get_the_excerpt(). '
  • ';
    $return .= '

} else {
// no posts can be found
/* Restore original Post Data */
return $return;
add_shortcode('latest_stickies', 'wpp_latest_sticky');

Use a shortcode [latest_stickies] to display the latest sticky posts. You can add this shortcode to any text widget, page or WP powered post.

Author Bio: Kerin Miller is an expert WordPress developer having years of experience in working with various web development technologies. Currently, she is working for a leading WordPress development company – Stellen Infotech. She is always trying to share her intangible knowledge with others on the web.