{"id":7016,"date":"2009-04-08T22:22:25","date_gmt":"2009-04-08T16:52:25","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=7016"},"modified":"2014-11-24T14:27:23","modified_gmt":"2014-11-24T08:57:23","slug":"sticky-posts-in-wordpress-themes","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2009\/04\/sticky-posts-in-wordpress-themes\/","title":{"rendered":"How to Enable Sticky Posts in WordPress Themes"},"content":{"rendered":"<p><strong>Sticky feature<\/strong> was introduced in WordPress 2.7 which let WordPress blogs highlight and send to top an <strong>important post<\/strong> on the front page despite the date of publication. But our theme did not support this feature when we selected the sticky checkbox.<\/p>\n<p>&nbsp;<\/p>\n<h3>Enable Sticky Posts in WordPress template<\/h3>\n<p><img decoding=\"async\" class=\"size-full wp-image-7017 alignright\" title=\"sticky on front page\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/sticky-front.gif\" alt=\"sticky on front page\" width=\"225\" height=\"53\" border=\"1\" \/><\/p>\n<p>If you are using a <strong>WordPress 2.7 compatible WordPress theme<\/strong>, then it will work out of the box without any of these tweaks. If you use an older theme, it actually works in 5 easy steps.<\/p>\n<ol>\n<li>In index.php <strong>add the tag<\/strong><br \/>\n<code>&lt;div &lt;?php post_class(); ?&gt;&gt;<\/code><br \/>\nbefore the article title and main post content<\/p>\n<p><code>&lt;h2&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/h2&gt;<br \/>\n&lt;?php the_content(); ?&gt;<\/code><\/li>\n<li><strong>Close the div tag<\/strong> at the end with <code>&lt;\/div&gt;<\/code><\/li>\n<li>Add <strong>.sticky css tag<\/strong> to your stylesheet style.css, and choose the attributes which will highlight the articles above other articles\n<pre><code>.sticky {\r\nbackground: #ff0000;\r\nborder: 1px solid #ccc;\r\n}<\/code><\/pre>\n<\/li>\n<li>Mark a <strong>post as sticky<\/strong> from the Quick Edit panel<\/li>\n<li>Visit your <strong>homepage<\/strong>, and check the Sticky post<\/li>\n<\/ol>\n<p>The best part about this feature is you can easily change the sticky tag from the <strong>Quick Edit <\/strong>menu from the WP Admin, which makes it easy to quickly keep changing the featured articles on the front page, and even mark multiple articles as sticky.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-7018\" title=\"sticky post\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/sticky-post.gif\" alt=\"sticky post\" width=\"310\" height=\"32\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/sticky-post.gif 310w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/sticky-post-300x30.gif 300w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/p>\n<p>Can you spot the sticky post on our homepage? Now you can do this too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sticky feature was introduced in WordPress 2.7 which let WordPress blogs highlight and send to top an important post on&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[17],"class_list":["post-7016","post","type-post","status-publish","format-standard","hentry","category-blogging","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/7016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=7016"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/7016\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=7016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=7016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=7016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}