Sticky posts are usually useful for highlighting important content on blogs. This helps you display the best articles on the front page of the blog whatever is the date of publication. There are two types of content that you need to pin on your home page:
A sticky post is a feature that not many people know about WordPress.
In this article, we will find out what you can do with a sticky post on WordPress.
When to use a WordPress sticky post?
Sticky posts are usually useful for highlighting important content on blogs. This helps you display the best articles on the front page of the blog whatever is the date of publication. There are two types of content that you need to pin on your home page:
The best content on the Blog
This is the most important content on your website. This includes in-depth articles, comprehensive guides, and the most popular posts.
This is also the best way to introduce new users to the blog, generate leads, and increase page views. You can highlight it on the website to make sure new users can find this article.
For example, you have a comprehensive article relating to a specific topic with good details. This article will be very useful for users. Therefore you need to place it at the top.
Important content based on time relevance
Types of posts that need to use sticky are posts that are relevant to the time such as product updates, announcements, and so on.
When you make an announcement about product updates on the blog, of course, you want users to immediately see it. Likewise, if you hold a giveaway for one month, then you want everyone to see it before the time limit runs out.
Things you can do with sticky posts on WordPress
Here are some interesting things you can do with sticky posts on WordPress:
Automatically install expired sticky posts
If you use sticky posts to highlight certain coupons or events, then you need to release them after the event is finished.
Just install and activate the Expire Sticky Posts plugin. After activation, you can set an expiration date for sticky posts.
After the expiration date, sticky posts will automatically become normal posts.
Sticky posts for categories
By default, sticky posts only appear on the front page of your site. But what if you want to display featured content on an archive category page?
Photo credit: Google |
You can do that by installing and activating the Sticky Post Category plugin. After activation, edit the post you want to display and select the sticky post category.
How to add sticky posts to a category in WordPress
Sticky posts help you add posting features to WordPress and display them differently on the homepage. Maybe you are asking how to add a sticky post on the category page.
By adding sticky posts to a category page, you can display the posting features of that category.
First, you need to install and activate the Sticky Post Category. There is no specific settings page for the plugin. Simply create a new post or edit an existing one, and you can see the new Category Sticky meta box in the post edit area.
If you want to set another sticky post in that category, then you must uncheck the category from the first sticky post. A post does not need to be filled in the same category. For example, a post in the Announcements category can be made sticky in the News category. Each category can only have one sticky post at a certain time. Also, each post can only be sticky for one category.
By default, the plugin adds a black border at the top and bottom of the sticky post category to distinguish it from other posts. You can disable it by checking the Hide Sticky Post Border box. When this box is not checked, the plugin adds category-sticky class to the sticky post category. You can use this in the stylesheet on the child theme:
[.category-sticky {
border: none;
background-color: # f5f5f5;
}]
Showing the latest sticky posts
Sticky posts are usually used for posting features to display the most interesting content. But after a while, the post feature disappeared under the archive. You can restore the old content feature again by showing a custom archive page or anywhere on your site.
Simply paste this code in the theme's function.php file or site-specific WordPress plugin.
[functionwpb_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 5 newest stickies (change 5 for a different number) */$sticky= array_slice( $sticky, 0, 5 );/* Query sticky posts */$the_query= newWP_Query( array( 'post__in'=> $sticky, 'ignore_sticky_posts'=> 1 ) );// The Loopif( $the_query->have_posts() ) {$return.= '<ul>';while( $the_query->have_posts() ) {$the_query->the_post();$return.= '<li><a href="'.get_permalink(). '" title="'. get_the_title() . '">'. get_the_title() . '</a><br />'. get_the_excerpt(). '</li>';}$return.= '</ul>';} else{// no posts found}/* Restore original Post Data */wp_reset_postdata();return$return; } add_shortcode('latest_stickies', 'wpb_latest_sticky');]
After adding this code, just add the code [latest_stickies] wherever you want to display the latest sticky post.
Sticky posts for custom post types
The sticky post feature is only available for WordPress posts, but this does not mean you cannot add this feature in other types of posts.
Simply install and activate the Sticky Custom Post Types plugin. After you activate the plugin, visit Settings >> Reading and activate sticky posts for any type of post you want.
How to hide sticky posts from WordPress
When using sticky posts, you will see that by default WordPress displays sticky posts at the top of all WordPress posts.
For example, if you have a loop to show the latest posts, sticky posts will appear at the top even if added.
To avoid this, simply ignore the ignore_sticky_posts argument in your WordPress query like this.
[<?php$args= array('posts_per_page'=> 10,'ignore_sticky_posts'=> 1);$the_query= newWP_Query( $args);if( $the_query->have_posts() ) : while( $the_query->have_posts() ) : $the_query->the_post();?>]
Styling on sticky posts
Do you want to style a sticky post?
Many WordPress themes use the post_class () function to automatically add classes for each post. If your theme already uses the post_class function, then you will see the sticky class added to your sticky post.
If your theme does not add a sticky class to the post container div, then you can add it yourself by adding the post_class () function to the post div or article container.
[<div id = "post - <? php the_ID (); ?> "<? Php post_class (); ? >>]
Now you can use the .sticky CSS class in the child theme stylesheet. Here are some basic CSS to get started:
[.sticky { background-color:#ededed;border:1px solid#f5f5f5;color:#272727;padding:5px;}.sticky:before {content: "Featured";color: #FFF;background: #f20000;padding: 10px;display: inline-block;text-align: right;float: right;font-weight: bold;text-transform: uppercase;}]
Like this, the display on the demo site uses the Twenty Twelve theme.
Hopefully, this article is useful to help you find out some interesting things in sticky posts on your WordPress site.
Photo credit: Google |
This article "Interesting Things You Can Do With Sticky Post on WordPress" is protected by
Everyone is using WordPress me and you. And I also want to go with but Sir, Should I create a WordPress blog if I have to manage with my phone.
ReplyDeletePlease reply
Yes you can manage your wordpress site with your mobile. You can find wordpress app in the google play store for android as well as in the Apple App Store for Iphone devices. You can create posts, manage your comments and track your adduidence on your mobile with thier free mobile app.😊
Delete