How To Show Some Content Until A Certain Date In Wordpress Using PHP

Posted by Weston Ganger

I needed to show an event poster on a clients site. I wanted it to automatically hide after a certain date. This solution saves the client money and saves your hassle.

Here’s how to do it using basic PHP


<?php if( strtotime('2015-10-16') > time() ): ?>
  <img src="images/my_img.png">
<?php endif; ?>

So now the poster will show until Oct 16, 2015. Just remember to clean up your code the next time you work on the project after this date.


Related External Links:

Article Topic:Software Development - Wordpress

Date:March 29, 2016

Recommended Posts