Dakatar da atingaukaka Shekaru a cikin Kasuwanci akan Gidan yanar gizonku na WordPress tare da wannan Shortcode

Shekaru a cikin Shortcode na Kasuwanci don WordPress

Ofayan mafi girman abubuwa game da WordPress shine sassauƙa don ƙirƙirar gajerun hanyoyi. shortcodes su ne madaidaiciyar zaren da za ku iya sakawa a cikin abun cikinku wanda ke samar da ingantattun abubuwa.

Ina taimaka wa abokin harka a wannan makon inda suke ɗaukar ɗayan samfuran su kuma mirgine shi zuwa sabon yanki. Shafin yana da ɗaruruwan shafuka kuma yana da aiki sosai. Kamar yadda muke aiki a kan jerin batutuwan da aka buga, wanda ya bayyana shi ne cewa akwai dinbin sakonnin yanar gizo, shafuka, da kira-zuwa-aiki wadanda suka yi magana da shekarun kamfanin a cikin kasuwanci.

Wasu shafuka suna da 13, wasu 15, wasu kuma daidai suke 17… duk ya dogara da lokacin da aka rubuta su. Wannan ɗayan waɗannan gyararrun gyare-gyare ne marasa buƙata don buƙatar sanya wannan lambar taƙaitacciyar hanyar iya ɗaukar ta daidai.

Abinda ya kamata muyi shine yin rijistar wata gajeriyar hanya wacce take ɗaukar shekara ta yanzu kuma mu cire ta daga shekarar da aka kafa kamfanin. Zamu iya yin rijistar gajeriyar hanya kuma mu sanya aikin a cikin taken shafin functions.php fayil:

function YIB_shortcode() {
   $start_year = '2003';
   $current_year = date('Y');
   $displayed_year = $current_year - $start_year;
   $years = $displayed_year;
   return $years;
}
add_shortcode('YIB', 'YIB_shortcode');

Abin da aikin yake yi shine ragi shekarar da muke ciki daga 2003 don fito da adadin shekarun da kamfanin ya kasance yana kasuwanci.

Don haka, idan ina so in rubuta tsawon lokacin da kamfanin ke kasuwanci a cikin abubuwan da shafin ya ƙunsa, kawai zan rubuta:

Our company has been in business for [YIB]+ years!

Tabbas, zaku iya zama mafi rikitarwa tare da wannan nau'in gajeren hanya… kuna iya amfani da HTML, hotuna, CSS, da sauransu. Amma wannan kawai misali ne mai sauƙi don kawai tabbatar da cewa rukunin yanar gizonku ya riga ya zama daidai!

Me kuke tunani?

Wannan shafin yana amfani da Akismet don rage spam. Koyi yadda aka sarrafa bayanan bayaninka.