v2.5.2
Giriş yap

wordpress ACF eklentisiyle gerisayım alanı yaptırmak istiyorum

erdem
582 defa görüntülendi

Merhaba ben header alanımda bir gerisayım aracı yapmak istiyorum fakat bunu wordpresin
ACF eklentisiyle yapmak istiyorum w3schools dan aldığım bi js kodu var ben acf kodunu nasıl
js koduna yediririm(biraz garip bi tabir oldu ama :)) ?
kodlar şöyle:

<h2>function.php</h2>

<?php

/*ACF*/
add_filter('acf/settings/path', 'my_acf_settings_path');
function my_acf_settings_path( $path ) {
    $path = get_stylesheet_directory() . '/inc/acf/';
    return $path;
}

add_filter('acf/settings/dir', 'my_acf_settings_dir');
function my_acf_settings_dir( $dir ) {
    $dir = get_stylesheet_directory_uri() . '/inc/acf/';
    return $dir;
    
}

?>

<h2>gerisayim.js</h2>


// w3schoolsdaki gerisaydırma kodu
<script>
// Set the date we're counting down to


var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();

  // Find the distance between now and the count down date
  var distance = countDownDate - now;

  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);

  // Display the result in the element with id="gerisay"
  document.getElementById("gerisay").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";

  // If the count down is finished, write some text
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("gerisay").innerHTML = "EXPIRED";
  }
}, 1000);
</script>

<h2>header.php</h2>
<h3>bu headerdaki gerisay id si ile gerisayim.js'i alabiliyorum</h3>

<!-- Display the countdown timer in an element -->
<p id="gerisay"></p>

<h3>bu kodu ise index.php ye yağıştırınca wordpressteki acf ile date time daki zamanı
çekebiliyorum<h3>

 <p><?php the_field('gerisayimalani','option'); ?></p>

<h3>benimde aklıma şu geldi eğer gerisayim.js'deki<h3>

var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();
//yerine 
var countDownDate = new Date("<?php the_field('gerisayimalani','option'); ?>").getTime();
//böyle yazabilsem yani javascript kodunun içine yazabilsem(ki olmuyor) wordpressten
//javascriptin artık doom manipülasyonmu ne deniyor onu yapabilcem ya da ben öyle sanıyorum
// yani wordpressteki acfye girdiğim değer gerisayim.jse gitcek ordan js'e işlenirse
//oda index.phpdeki 
<p id="gerisay"></p>
//tagının içine gidecek ve sitede gerisayım oluşcak

Sorum çok uzun biliyorum okuyup cevap verene şimdiden teşekkür ederim daha kolay
bi yolu varsa da çekinmeyin söyleyin :)

Cevap yaz
Cevaplar (0)
Henüz kimse cevap yazmadı. İlk cevap yazan sen ol!