Support » Requests and Feedback » Suggestion for Plugin: Mark Expired posts with watermark

  • Hi,
    I have a suggestion for a WordPress plug-in:

    Have one that marks expired posts with an “Expired” (user defined jpg/art?) watermark over the general post area…

Viewing 5 replies - 1 through 5 (of 5 total)
  • Here is one quick method for you. This function can be used to add an extra CSS declaration to the element you choose if the post is older than a specified number of days:

    $date_check_code = '';
    if (is_single()) {
      $days = 90;
      if (time() - strtotime($posts[0]->post_date_gmt) > ($days * 86400)) {
        $date_check_code = ' class="expired" ';

    As you can see, the number of days is set to 90 in this example. And if the post being viewed is older than that, it sets the $date_check_code variable to ‘ class=”expired” ‘

    You can then use that class on whatever you want, such as the div for the post. Here is an example for the default theme – replace this:

    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">

    With this:

    <div <?php echo $date_check_code; ?> <?php post_class() ?> id="post-<?php the_ID(); ?>">

    Of coure you can apply the extra CSS to any element, and define the .expired class however you like in your themes CSS file.

    Btw, this code is meant to be used in your themes single.php – for when viewing a full post.

    Should be a start to get you going 🙂

    Dragon Design, you are a bloody little genius. Thank you!

    What about dictating when the post expires through a date provided in a field in each post? Is that doable using this method or would a plugin be necessary in that circumstance?

    I know there’s a Post Expirator plugin, but I’d like to keep my expired posts up and published, just greyed out or something along those lines.

    Dagon Design


    You could certainly do the same type of thing for that. Just use a custom post value, and retrieve it in the code, comparing it against the current date.



    Thanks, Dagon. I sent you an email through your site about seeing if you might be able to help me on this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Suggestion for Plugin: Mark Expired posts with watermark’ is closed to new replies.