0

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

1 Answer 1

2

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' ) ) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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