Nres Txhim Kho Xyoo hauv kev lag luam ntawm koj lub vev xaib WordPress nrog qhov luv luv no

Xyoo hauv Kev Ua Lag Luam Shortcode rau WordPress

Ib qho loj tshaj plaws txog WordPress yog kev yoog raws kom tsim ua shortcodes. Shortcodes yog qhov hloov pauv txoj hlua uas koj tuaj yeem ntxig rau koj cov ntsiab lus uas xa cov ntsiab lus dynamic.

Kuv tabtom pab ib tus neeg lag luam lub lim tiam no qhov twg lawv noj ib qho ntawm lawv cov khoom thiab dov nws mus rau hauv ib thaj chaw tshiab. Lub xaib yog ntau pua nplooj ntawv thiab tau ua haujlwm heev. Raws li peb tau ua haujlwm nyob rau hauv daim ntawv teev cov npe ntawm cov teeb meem, ib qho uas tau tshwm sim yog tias muaj kaum ob ntawm cov ntawv blog, nplooj ntawv, thiab hu-ua haujlwm uas tau hais rau lub tuam txhab xyoo hauv kev lag luam.

Qee cov nplooj ntawv muaj 13, qee 15, qee tus yog tus lej ntawm 17 ... txhua nyob ntawm thaum lawv tau sau. Qhov no yog ib qho ntawm cov kev kho tsis tseem ceeb uas xav tau los ua kom qhov luv luv ntawd tuaj yeem kho txig.

Txhua yam peb yuav tsum tau ua yog sau npe tus lej shortcode uas siv lub xyoo tam sim no thiab rho tawm nws los ntawm lub xyoo tsim lub tuam txhab. Peb tuaj yeem sau npe rau lub shortcode thiab muab tso rau qhov haujlwm nyob hauv tus xaib lub ntsiab functions.php cov ntaub ntawv:

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

Qhov haujlwm ua dab tsi yog rho tawm xyoo tam sim no los ntawm 2003 kom tuaj txog qhov tsim nyog xyoo uas cov tuam txhab tau ua lag luam.

Yog li, yog tias kuv xav sau ntev npaum li cas lub tuam txhab tau ua lag luam nyob rau hauv cov ntsiab lus ntawm lub xaib, Kuv tsuas yog sau:

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

Tau kawg, koj tuaj yeem tau deb dua nrog cov hom shortcode no ... koj tuaj yeem siv HTML, duab, CSS, thiab lwm yam tab sis qhov no tsuas yog ib qho piv txwv yooj yim xwb kom paub tseeb tias koj lub xaib twb muaj tseeb!

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.