WordPress: Rubuta lambar Gaji daga Jigon Iyaye a Jigogin Yaron ku

API na WordPress

Da kyau, an ɗan ɗan lokaci tun lokacin da na raba wasu shawarwari kan shirye-shirye a cikin WordPress. Kwanan nan, Na dawo kan benci na tura lambar don duk abokan cinikinmu kuma abin farin ciki ne mu dawo cikin jujjuya abubuwa. Wataƙila kun lura da sabon haɗin haɗin Farin Jarida a cikin duk rukunin yanar gizon - wannan ya kasance mai kyau fun aikin!

A yau, ina da wani batun daban. Yawancin abokan cinikinmu suna da maɓallan aiwatarwa ta hanyar gajeren gajeren taken taken iyaye. Ofaya daga cikin abokan tarayyarmu a vatedaukaka Tallace-tallace ta Tallace ta nemi idan za mu iya yin wani bibiyar abubuwan da ke faruwa a kan maɓallan tun da sun kasance manyan kira-zuwa-ayyuka a cikin shafukan. Maballin gajerun hanyoyi ba komai bane face alamar anga wacce aka tsara ta da kyau sosai ta amfani da jerin azuzuwan da zaɓuɓɓukan gajerun hanyoyin ke da su.

Saboda wannan, muna buƙatar ƙara taron onclick zuwa rubutun anga don yin rijistar taron. Ga abin da zai iya kama:

Button Gida

Matsalar, ba shakka, akwai cewa akwai gajeriyar hanya a cikin mu taken iyaye kuma ba ma so mu gyara taken iyaye. Kuma, tunda an yi amfani da gajeriyar hanya ta kowane fanni a duk faɗin rukunin yanar gizon, mu ma ba ma son ƙirƙirar sabuwar gajeriyar hanya.

Maganin yana da kyau. Da WordPress API Yana baka damar cire lambar gajeriyar hanya! Don haka, a cikin taken yaranmu, zamu iya cire lambar gajeren hanya, sannan mu maye gurbin ta da sabon aikin gajeren hanyar aiki:

add_action ('bayan_ saitawa_theme', 'kiran_a_yan_kare_setup');
aiki Call_child_theme_setup () {remove_shortcode ('old_button_function_in_parent_theme'); add_shortcode ('maballin', 'new_button_function_in_child_theme'); }
aiki sabon_button_function_in_child_theme ($ atts, $ content = null) {... sabuwar lambar taka tana nan ...}

A cikin sabon aikin maɓallin (a cikin myan aikin Childan Childana na Childan yaro.php), Na sake rubuta aikin gajeriyar hanya don sanya abubuwan da ke faruwa akanClick. Kayan aikin yana aiki da kyau kuma yanzu yana bin diddigin Google Analytics!

Me kuke tunani?

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