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.

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
add comment

1 Answer

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
add comment

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.