I had the idea to make sticky posts expire after a certain period of time.
FYI, I am using a custom post type along with custom field suite and created sticky posts by creating a boolean custom field.
premium is a true/false custom field which returns the value
1 if the checkbox is checked (which makes a post a featured post)
If I created another custom field to set the expiration date, how would I set the sticky-custom-field value to 0 when the expiration date is reached?
What I mean is (in written english):
- check for a custom field with the key "premium"
- check if custom field "premium" has value 1
- check for a custom field with the key "expiration_date"
- check if "expiration_date" value is in the past, but not today
- if "expiration_date" is in the past, set "premium" value to 0
Can someone assist making this a function?
I'd begin with the following (please excuse the style, I am just trying to provide ideas)
global $post; global $cfs; if ( '1' = $cfs->get('premium') && ' ' != $cfs->get('expiration_date') ) : $current_date = date(Y-m-d); $expiration_date = $cfs->get('expiration_date'); if( // I'm stuck here... ) .... date_post_meta( $post->ID, 'premium', '1', '0' ); // set premium field from 1 to 0 for every post that matches endif;