Created
February 22, 2017 10:12
-
-
Save campusboy87/727e91964cf24b1be2e3ac57c71b8d64 to your computer and use it in GitHub Desktop.
Выводит дату поста + 3 месяца
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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