WordPress: Ngatur CSS yen Kiriman sing Diterbitake Dina Iki

wordpress logo

I've been wanting to add the little calendar graphics to my posts for a while now. I wrote two classes for the date div and set the background image differently based on whether or not the post was written today. Thanks to Michael H ing Forum Dhukungan WordPress, I finally got my statement correct! Here's what I did. I have a background image set for the div class date:


For today's div, I set a different background image applied to a div class named the_date_today:


Now that I've got those set, I need to write some code that adds the “_today” if the post was written today:

post_date_gmt); if($post_date==gmdate('Ymd')) { echo '_today'; } ?>">

Mangkene cara iki:

  1. Aku nyetel variabel sing diarani $ post_date padha karo tanggal posting kasebut diformat dadi Ymd.
  2. I write an if statement so that if that variable equals today's date (formatted as Ymd as well), I add “_today”

Voila! Now I have a calendar graphic that displays whether or not the post was written today! I just need to adjust for timezone and I'll have it made!

5 Komentar

  1. 1

    Hei Doug. Lunyu tenan!

    Cathetan sisih, aku saranake sampeyan mindhah kothak centhang 'lengganan' ing ndhuwur tombol tambah komentar… kanggo aku sing luwih ramah pangguna.

    Proyek gedhe ing grafis tanggalan lan CSS anyar.

    • 2

      Matur suwun Sean.

      Posisi kothak centhang wis disengaja. Nyelehake ing njaba lapangan liyane bakal nggawe pamisahan ing antarane lan lapangan liyane sing sempit. Kanthi nyelehake ing sacedhake tombol, nggawe pilihan ing cedhak tumindak, iki bisa uga nyebabake luwih akeh wong sing ora kejawab nalika ngrampungake pikirane ing komentar lan pindhah.

      Siji bab sing ilang yaiku mandeg tab sing tepat. Aku bakal mbenerake.

  2. 3
  3. 5

    Ok, aku ora ngerti yen sing sampeyan maksudake babagan nyetel kanggo GMT.

    Aku yakin sampeyan ana ing ndhuwur kode mr kethèk 🙂 nanging bisa uga sampeyan bisa nindakake sawetara 'yen' pratelan ndeleng wektu server sampeyan?

    yen tanggal / wektu server X dibandhingake karo tanggal kirim / wektu nuduhake gambar X utawa sing ana efek kasebut.

Apa sampeyan mikir?

Situs iki nggunakake Akismet kanggo ngurangi spam. Sinau babagan proses data sampeyan.