WordPress: Sinthani CSS ngati Post Yasindikizidwa Lero

logopress logo

Ndakhala ndikufuna kuwonjezera zojambula zazing'ono pakalendala yanga posachedwa tsopano. Ndinalemba makalasi awiri a tsiku la div ndikuyika chithunzi chakumbuyo mosiyana kutengera kuti zomwe zalembedwazo zidalembedwa lero kapena ayi. Chifukwa cha Michael H m'mabwalo a WordPress Support, Pamapeto pake ndinayankha! Nazi zomwe ndidachita. Ndili ndi chithunzi chakumbuyo cha tsiku la div:


Kwa div lamasiku ano, ndidakhazikitsa chithunzi chosiyananso ndi gulu la div lotchedwa_date_today:


Tsopano popeza ndatha kuyika, ndiyenera kulemba nambala yomwe imawonjezera "_today" ngati uthengawu udalembedwa lero:

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

Umu ndi momwe izi zimagwirira ntchito:

  1. Ndayika chosinthika chotchedwa $ post_date chofanana ndi tsiku la positi yojambulidwa ngati Ymd.
  2. Ndikulemba mawu kuti ngati kusinthaku kuli kofanana ndi tsiku lamasiku ano (lopangidwira monga Ymd), ndikuwonjezera "_today"

Voila! Tsopano ndili ndi chithunzi cha kalendala chomwe chikuwonetsa ngati cholembedwacho chidalembedwa lero! Ndikungoyenera kusintha nthawi yayitali ndipo ndiyipanga!

5 Comments

  1. 1

    Hei Doug. Ndizovuta kwambiri!

    Cholemba cham'mbali, ndikupemphani kuti musunthire 'pezani' bokosi lanu pamwamba pa batani la ndemanga ... kwa ine ndizosavuta kugwiritsa ntchito.

    Ntchito yabwino pazithunzi zanu za kalendala ndi CSS.

    • 2

      Zikomo Sean.

      Kuyika kwa bokosi la cheke ndicholinga. Kuyika kunja kwa madera ena kumatha kulekanitsa pakati pawo ndi minda ina yolimba. Mwa kuyiyika pafupi ndi batani, ikuyika chisankho pafupi ndi chochita, izi zitha kupangitsa kuti anthu ambiri aziphonye akamamaliza malingaliro awo mu ndemanga ndikusunthira kuti apereke.

      Chinthu chimodzi chomwe chikusowa ndi kuyimitsidwa koyenera kwamabuku, komabe. Ndikonza kuti ndikonze izi.

  2. 3
  3. 5

    Chabwino, sindinadziwe kuti ndi zomwe mumatanthauza pakusintha GMT.

    Ndikutsimikiza kuti muli pamwamba pake mr code monkey 🙂 koma mwina mutha kupanga mawu akuti 'ngati' poyang'ana nthawi yanu ya seva?

    ngati deti / nthawi ya seva ndi X poyerekeza ndi positi tsiku / nthawi yowonetsa X chithunzi kapena china chake.

Mukuganiza chiyani?

Tsambali likugwiritsa ntchito Akismet kuchepetsa spam. Phunzirani momwe deta yanu ikufotokozera.