maik72
maik72

Reputation: 1

Expiring date for content wordpress

http://wordpress.org/extend/plugins/simple-timed-plugin/

Im using this function to dissapear(not delete) expired posts:

<?php if (function_exists('simple_timed_content')) : ?>
<?php if (simple_timed_content("offdate=20120309 offtime=2350")) : ?> 
 Some content goes here 
<?php endif; ?> <?php endif; ?>

I want to use as dates from custom fields like this:

 <?php if (simple_timed_content("offdate='$end_date' offtime='$end_time'")) : ?>

where : `

$end_date=date( 'Ymd', strtotime( get_post_meta( $Post->ID, "_EventEndDate", true),     time()));`

and

$end_time=date( 'HM', strtotime( get_post_meta( $Post->ID, "_EventEndDate", true), time()));`

Assuming allways that _EventEndDate value is : Ymd HM (20120309 2350) How would be the complete code for this to work?

My other option is to use this code i found :

www.rockia.com/2010/01/modify-you-wordpress-theme-to-enable-an-expiration-for-your-posting

but it doesnt seem to work with my

www.wordpress.org/extend/themes/bombax

where loop is in single.php file

If someone could help I would appreciate it. Im new to php. Thank you in advance

Upvotes: 0

Views: 399

Answers (1)

w3uiguru
w3uiguru

Reputation: 5895

I have different way to accomplish this try below

Edit your theme and replace your current WordPress loop by this "hacked" loop:

<?php
if (have_posts()) :
     while (have_posts()) : the_post(); ?>
         $disappeartime = get_post_custom_values('disappear');
         if (is_array($disappeartime)) {
             $disappearstring = implode($disappeartime);
         }

         $secondsbetween = strtotime($disappearstring)-time();
         if ( $secondsbetween > 0 ) {
             // For exemple...
             the_title();
             the_excerpt();
         }
     endwhile;
endif;
?>

To create a post with date/time disappear, just create a custom field. Give it disappear as a key and your date/time (format: mm/dd/yyyy 00:00:00) as a value. The post will not show after that time stamp.

Upvotes: 0

Related Questions