Posted By

dwest on 02/20/08


time date post wordpress and Expiration

Versions (?)

Wordpress Snippet to set Post Expiration time and date

 / Published in: PHP

  2. <?php
  3. $expirationtime = get_post_custom_values('expiration');
  4. if (is_array($expirationtime)) {
  5. $expirestring = implode($expirationtime);
  6. }
  7. $secondsbetween = strtotime($expirestring)-time();
  8. if ( $secondsbetween > 0 ) {
  9. ?>
  10. ***LOOP HERE***
  12. ***AFTER LOOP***
  13. <?php
  14. }
  15. ?>

Report this snippet  


RSS Icon Subscribe to comments
Posted By: dwest on February 20, 2008

Enter your Custom Field Key as expiration with a value specified as mm/dd/yyyy 00:00:00

The post will not show after that time stamp.

Posted By: ukbob on July 26, 2009

Hi - I just came across this post and it appears to be exactly what I need to expire my contributor posts. Not being a developer per se, I need to ask your advice: Firstly, my server timestamp is in this format: yyyy/mm/dd hh:mm:ss - what would I need to alter to make the code work? Secondly, it would be very helpful to know where to put the "after loop" code in a multi-loop page. If I put it at the very end of all my loops - then all my content disappears - if I put it elsewhere - the whole page disappears. This looks to be very useful - just need some pointers.......! thanks very much.

You need to login to post a comment.