Working on a real estate website and setting Open House dates and times using drop downs in a Custom Meta Box. Example drop down below:

<select name="sale_listing_open_house1_start_day" id="sale_listing_open_house1_start_day">  
        <option value="monday" <?php selected( $selected, 'Monday' ); ?>>Monday</option>  
        <option value="tuesday" <?php selected( $selected, 'Tuesday' ); ?>>Tuesday</option>  
        <option value="wednesday" <?php selected( $selected, 'Wednesday' ); ?>>Wednesday</option>  
        <option value="thursday" <?php selected( $selected, 'Thursday' ); ?>>Thursday</option>
        <option value="friday" <?php selected( $selected, 'Friday' ); ?>>Friday</option>  
        <option value="saturday" <?php selected( $selected, 'Saturday' ); ?>>Saturday</option>
        <option value="sunday" <?php selected( $selected, 'Sunday' ); ?>>Sunday</option>  

Let's say there's a drop down for the end day, month, date and time ... Is there any way to format this so that the Open House will expire once the date/time has passed what was specified in the drop down?

  • 2
    What do you mean by expire? That the post is deleted/changes status? – Stephen Harris Mar 6 '12 at 1:46
  • Currently, the post is set to display a badge with the date/time of the open house using the tag "open house" in conjunction with a custom field that display's if the post has_tag(). Ideally, I'd like that to go away once the date set in the drop down passes. – Charles Mar 15 '12 at 1:04

Have a look at the Post Expirator plugin.

The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins area that will allow you to seperataly control whether or not posts/pages are either deleted or changed to draft status.

  • Thanks, but I don't want to change the post status... just have a function that maybe checks the date used in the dropdown and hooks into delete_post_meta to remove the Open House info. Maybe a nightly cron job or something... – Charles Mar 15 '12 at 22:37

I am not sure to clearly understand what you want but why won't you use a Javascript timer to "lock" it after a certain time is passed?

Otherwise, you'll have to use Database/PHP and check the expiration date. I do not see how you can do otherwise ( with the given information ).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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