Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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';
       }
       else
       {
       return '';
       }
    }

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

.My_css_class_for_older_posts h2{
    color:red;
 }
share|improve this answer

Your Answer

 
discard

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.