What is a Sticky post?
Sticky posts are useful when any blogger wants that post to be shown on the front page or home page of his/her blog. Whenever you declare the post as ‘sticky’ from that moment the particular post will appear on the home page of your blog forever. 😉
How to add a sticky post?
- Write on the post editor
- Go to the publish box on the right hand side
- Under the visibility section-> Click on the Stick check box
- Publish the post (see image below)
This post will always appear on the home page. If you want the post to show according to date of other published posts then you need to add the code below in your “index.php” or “home.php” (in the php file of theme which shows blog home page).
$sticky = get_option(‘sticky_posts’); $args=array( ‘caller_get_posts’=>1, ‘showposts’=>4, );// change showposts count as you want query_posts($args);
It must be added before the WordPress loop. By the above code you can get all the latest published or published/sticky post by the default way as WordPress shows.
Hope this post helped you in solving the sticky post problem. If you have any other way of doing so please share it through your comments.
This is really helpful, as wordpress by default shows the recent posts. I was also searching the way to override it…thanks for sharing…!
I have been struggling to put few posts as sticky on the home page on my other blog but may be it was clashing with the business style template used. It didn’t allow sticky posts, but thanks for the info anyways.
Hi guys..nice tip… just to add that since you wrote this : ‘caller_get_posts’ is now deprecated and since WP3.1 ‘ignore_sticky_posts’ => 1 is used in its place … codex page on sticky posts up dates the change
Thanks Michael for your update. 🙂