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

I'd like to have a conditional tag that is something like this:

<?php if (is_single()&&is_older_than_october_2011()){do this}; ?>

The part I'm trying to highlight is the is_older_than_october_2011() aspect. There doesn't appear to be any conditional tag that WP offers which has this functunality?

Thanks, Brad

share|improve this question

Here is function I have for old posts:

function is_old_post( $days = 14 ) {

    if( !is_single() )
        return false;

    $id = get_the_ID();
    $date = get_post_field( 'post_date', $id );

    if( strtotime( $date ) < strtotime( "-{$days} days" ) )
        return true;

    return false;

Not tested, but you can probably tweak condition to be something like:

if( strtotime( $date ) < strtotime( 'October 2011' ) ) 
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.