Skip to content

Instantly share code, notes, and snippets.

@campusboy87
Created February 22, 2017 10:12
Show Gist options
  • Save campusboy87/727e91964cf24b1be2e3ac57c71b8d64 to your computer and use it in GitHub Desktop.
Save campusboy87/727e91964cf24b1be2e3ac57c71b8d64 to your computer and use it in GitHub Desktop.
Выводит дату поста + 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(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment