Skip to content

Instantly share code, notes, and snippets.

@Dimasmagadan
Last active December 31, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dimasmagadan/6193782 to your computer and use it in GitHub Desktop.
Save Dimasmagadan/6193782 to your computer and use it in GitHub Desktop.
#WordPress: self expiring posts
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}
$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
the_title();
the_excerpt();
}
endwhile;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment