Home » Knowledge Base

How to set expiration date for a post using custom fields?

18 November 2009 No Comment

Custom fields provide  a strong tool for developers to make it more user friendly and customizable.

Today, we will see how we can assign an expiration date to a post, so the post will disappear after a particular date:

1)      Change the default loop in your index.php file as mentioned below:


 

 

2)      Now, when you add/edit a post, add a custom field expiration and assign the date as value(with the format mm/dd/yyyy 00:00:00). The post will disappear after that date from the home page.

Note that if you do not assign the custom field to a post, that post will not appear on your home page. This code needs some modification for the same.

You may like these articles :

  1. How to Digg your wordpress post? Please follow each step carefully. 1) Register at digg.com. You...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.