campusboy87
2/22/2017 - 10:12 AM

Выводит дату поста + 3 месяца

Выводит дату поста + 3 месяца

function datePost() {
    $in_date = date('Y-m-d');   
    $date = get_the_date( 'Y-m-d');
    $datepost = date_create(get_the_date( 'Y-m-d'));
    date_add($datepost, date_interval_create_from_date_string('3 months'));
    $to_date = date_format($datepost, 'Y-m-d'); 
    if( $date < $to_date && $in_date < $to_date )
    {
       echo '<span class="newcategory"></span>';
    }
    else
    {
        echo '';
    }
}
add_action('get_posts', 'datePost', 10, 1);

<?php if ( function_exists( 'datePost' ) ) datePost(); ?>