0

I'm scheduling and displaying all my posts in the future. I'd like to somehow add some text after the post title when the publish date is reached. In effect the post will expire at the time of the publish date and therefore I need to suffix the title witH [THIS POST IS EXPIRED].

  • Do you actually display scheduled posts before their scheduled time? How do you handle that their status isn't yet set to publish in that case? – Rarst Oct 9 '15 at 19:43
  • @Rarst Yes I do. I'm using the plugin "No Future Posts (wordpress.org/plugins/no-future-posts) " to publish them before the post date. Will this plugin affect what I want to achieve? – Pete May 7 '16 at 8:04
0

I've found the code below that does what I want except it isn't accurate to the hour. It is only accurate to the whole day, so if my post expires in the morning it still shows it as current in the afternoon.

How would this be able to be more accurate to the hour?

<?php if (strtotime($post->post_date) > strtotime('+1 minute')): ?>
<p>current</p>
 <?php elseif (strtotime($post->post_date) > strtotime('-999999999 days')) : ?>
<p>expired</>
<?php else : ?>
 <?php endif; ?>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.