Kāohi i ka hoʻohou ʻana i nā makahiki i ka ʻoihana ma kāu Pūnaewele WordPress me kēia Shortcode

Nā makahiki i ka Shortcode Pakihi no WordPress

ʻO kekahi o nā mea nui e pili ana iā WordPress ka maʻalahi e kūkulu i nā pōkole. shortcodes he mau kaula kuapo i hiki iā ʻoe ke hoʻokomo i kāu ʻike i hāʻawi i ka ʻike ikaika.

Ke kōkua nei wau i kahi mea kūʻai aku i kēia pule kahi lākou e lawe nei i kekahi o kā lākou huahana a ʻōwili iā ia i loko o kahi kikowaena hou. He mau haneli ʻaoʻao ka pūnaewele a he hana nui nō ia. E like me kā mākou e hana nei ma ka papa inoa hits o nā pilikia, ʻo kahi mea i hāpai ʻia aia he nui o nā pou blog, nā ʻaoʻao, a me nā heahea i kamaʻilio i nā makahiki o ka ʻoihana i ka ʻoihana.

Loaʻa i kekahi mau ʻaoʻao he 13, kekahi 15, pololei kekahi ma ka 17… ma muli o ka wā i kākau ʻia ai. ʻO kēia kekahi o nā hoʻoponopono pono ʻole e pono ai e hana i kahi shortcode i hiki ke lawelawe pono.

ʻO nā mea a mākou e pono ai e hoʻopaʻa inoa i kahi code pōkole e lawe i kēia makahiki i kēia manawa a lawe iā ia mai ka makahiki i hoʻokumu ʻia ai ka ʻoihana. Hiki iā mākou ke hoʻopaʻa inoa i ka shortcode a kau i ka hana ma loko o ka pūnaewele o ka pūnaewele functions.php pūnaewele:

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');

ʻO ka hana e huki i ka makahiki i kēia manawa mai 2003 e piʻi me nā helu kūpono o ka ʻoihana i ka ʻoihana.

No laila, inā makemake wau e kākau i ka lōʻihi o ka ʻoihana ma loko o ka ʻoihana o ka pūnaewele, kākau wale wau:

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

ʻOiaʻiʻo, hiki iā ʻoe ke kiʻi ʻoi aku ka paʻakikī me kēia ʻano pōkole ... hiki iā ʻoe ke hoʻohana i ka HTML, nā kiʻi, CSS, a pēlā aku. Akā he laʻana maʻalahi wale kēia e hōʻoiaʻiʻo i ka pololei o kāu pūnaewele.

Pehea kou manaʻo?

Ke hoʻohana nei kēia pūnaewele i ka Akismet e ho'ēmi i ka spam. E aʻo pehea e hanaʻia ai kāuʻikeʻikepili.