WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to set a CSS stylesheet or a theme for articles that were published before X date?

The reason I ask is that we've just redesigned our website and some pages have images that are wider than the page size now.

share|improve this question
Why not use max-width CSS property on images? That will keep wider images within page size, and normal images aren't affected. – its_me Jun 28 '12 at 10:52
up vote 1 down vote accepted

I php you can create an anchor class based on the desired date. I haven't tested it, but it should be something like this:

    // your relevant html parent element
    <div class="<?php echo getOlderPostsClassName( '5/5/2012',the_time() ); ?>">

    function getOlderPostsClassName($untilDate, $wordpressPostDate)
       $start = strtotime($untilDate);
       $end = strtotime($wordpressPostDate);
       if ($start-$end > 0)
          return 'My_css_class_for_older_posts';
       return '';

Then in your Css you can target differently any descendant element:

.My_css_class_for_older_posts h2{
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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