function custom_countdown_shortcode($atts) {
// Varsayılan ayarlar
$atts = shortcode_atts(
array(
'year' => date('Y'),
'month' => '1',
'day' => '1',
'hour' => '0',
'minute' => '0',
'second' => '0',
),
$atts,
'countdown'
);
// Hedef tarihi oluşturma
$target_date = mktime(
$atts['hour'],
$atts['minute'],
$atts['second'],
$atts['month'],
$atts['day'],
$atts['year']
);
// Şu anki zamanı al
$current_date = time();
// Geri sayım süresi
$diff = $target_date - $current_date;
if ($diff > 0) {
// Geri sayımı formatlama
$days = floor($diff / (60 * 60 * 24));
$hours = floor(($diff - $days * 60 * 60 * 24) / (60 * 60));
$minutes = floor(($diff - $days * 60 * 60 * 24 - $hours * 60 * 60) / 60);
$seconds = $diff - $days * 60 * 60 * 24 - $hours * 60 * 60 - $minutes * 60;
return "$days gün, $hours saat, $minutes dakika, $seconds saniye";
} else {
return "KUTLU OLSUN";
}
}
add_shortcode('countdown', 'custom_countdown_shortcode');Bu kodu functions.php'ye ekleyebilirsiniz. Kısa kod ile şu şekilde çalıştırabilirsiniz=
[countdown year="2024" month="4" day="1" hour="0" minute="0" second="0"]
Bu kısa kodda istediğiniz düzenlemeyi yapabilirsiniz. Girdiğiniz değerlerden geri sayım yapacaktır.
Geri sayım bittiği zaman da "KUTLU OLSUN" yazacaktır.