Set post expiration dates
If you are running a time limited contest or offering a discount, for example, you will need to expire the post at a specific time. You can manually remove the article or you can make it expire automatically.
All you need to do is replace your WordPress Loop with this code:
if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values(‘expire’);
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
// For example…
the_title();
the_excerpt();
}
endwhile;
endif;
?>
Once you have done that, you can use custom fields to set the expiration date.
The key for this is ‘expire’ and use the the following date format: mm/dd/yyyy 00:00:00
Please note – This does not remove or un-publish the article, instead it just excludes the article from being displayed in the loop.
WordPress support
Wordpress Themes & plugins
WordPress Books
- Build Your Own Wicked WordPress Themes
- The Best Little Book On Creating A Parenting Blog
- ProBlogger: Secrets for Blogging Your Way to a Six-Figure Income Reviews
- WordPress Revenue Secrets
- 250+ Top Free WordPress Plugins To Multiply Your Web 2.0 Marketing Profits!
- CSS: The Missing Manual Reviews
- Twitter and WordPress: Multiply the Power of Each To Generate More Traffic
- Start Your Own Blogging Business, Second Edition
- Nations Apart
- WordPress Search Engine Success: How To Maximize SEO & Income From WordPress Websites
- Guide to Easy Website Transfers – WordPress Blogs Reviews
- All About Blogging
- WordPress For Dummies
- How to Start and Own Your WordPress Blog ~ Made Easy
- WordPress Plugin Confidential + WordPress Theme Confidential Bonus Book






