WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want some how to mark the post that has been featured (was a sticky post) in the category template. in wordpress logic it should be something like -



share|improve this question
I think you could hook on 'save_post' in the admin, to update a meta key ; and then run a query to call all posts that have that meta key. – Simon Mar 22 '12 at 17:46
@Simon, this is a possibility but i'm trying to avoid a lot of custom coding here... if i won't have any other choice maybe I'll go that road eventually... – Asaf Chertkoff Mar 22 '12 at 18:31
Well, there's nothing built-in to do what you want. A post is sticky or not - no memory of if used to be. That means custom code ^^ - or keep every post sticky forever, and just display the last X. – Simon Mar 22 '12 at 19:04
up vote 1 down vote accepted

Check if »sticky«

There's the is_sticky()-Conditional Tag, which you can read about in core here.

How-to mark as »sticky«

This works for posts, that have the "stick to the front page" check box checked:

How »sticky« works internally

So basically the function checks if the post-ID is inside get_option( 'sticky_posts' );. That means that you can't question if a post was "sticky". You can only check which posts are currently "sticky".

Style as many »sticky« posts as you need & style »sticky« them specially

So your only chance would be to show only the number of sticky posts that you need 1) on the front page and skip the rest. Then you can apply to all your archive posts the post_class(); (inside the loop). This adds different classes to the post, but also the .sticky class for "sticky" posts. Which means, that you now have a way to style them differently.

.sticky {
    color: #FF00FF;
    background-color: #009ee0;

1) You can get the newest sticky posts with $newest_stickies = array_slice( rsort( get_option( 'sticky_posts' ) ), 0, 2 ); - change the last number to the number of posts you need. To add them to the loop, use 'post__in' => $newest_stickies as argument for your main/front-page query.

share|improve this answer
the issue is what will happened when i will un-check the post as sticky? what i need is a way to know that the post was sticky in the past, when now it isn't... what do you say? – Asaf Chertkoff Mar 22 '12 at 18:28
There's no chance to keep this data. When you uncheck the check box, then you loose the post-ID from the array in the options table entry. So the only chance is to let them stay checked as sticky and only show those that you want where you want (home/front page). In the archive pages, you can then access them as described above. That's the way it's meant to be from core side. – kaiser Mar 22 '12 at 18:31
Hmmm... maybe you're right, but I'll let this question hang a little bit before I'm deciding that this is it. thanks. – Asaf Chertkoff Mar 22 '12 at 18:32
The only other option is to intercept the post on update, move it to another option and then question on every loop run if the post ID is inside the new option and then add another class. I'd personally go with the future-proof, default core-solution instead of hacking lots of lines of code into a plugin for a task that's already done. Sidenote: You don't get rep points back if you don't nominate an answer as solution. :) – kaiser Mar 22 '12 at 18:38
i know. but I want to. cause you spent your time to help me with a solution. – Asaf Chertkoff Mar 23 '12 at 17:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.