Your Ad Here

Posted By

dwest on 02/20/08


Tagged

time date post wordpress and Expiration


Versions (?)

Wordpress Snippet to set Post Expiration time and date


 / Published in: PHP
 

  1. ***BEFORE LOOP
  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***
  11.  
  12. ***AFTER LOOP***
  13. <?php
  14. }
  15. ?>

Report this snippet  

Comments

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.

Posted By: fendichen on October 7, 2010

hi friend, do you know cheap ghd, cheap mbt shoes, christian louboutin shoes hot sell online recently?

we are china wholesaler company, offer good quality nike dunks, ghd mk4, cheap soccer jerseys online, cheap jerseys online enjoy much discount.cheap nike dunks,nike shox why are you hestitate, welcome for retail, dropship, and wholesale orders.

You need to login to post a comment.