WordPress: Nyora Shortcode Kubva Kumusoro Wevabereki MuMwana Wako Dingindira

WordPress API

Zvakanaka, zvave nenguva yakati rebei kubva pandakagovana matipi ekuronga muWordPress. Munguva pfupi yapfuura, ndadzoka pabhenji ndichiendesa kodhi kune vese vedu vatengi uye zvave zvichinakidza kudzokera mukufambiswa kwezvinhu. Iwe unogona kunge wakacherekedza nyowani Yekushambadzira Whitepaper inosanganiswa munzvimbo yese saiti - iyo yanga iri chaiyo chirongwa chinonakidza!

Nhasi, ndanga ndine imwe nyaya. Vazhinji vedu vatengi vane mabhatani akaiswa kuburikidza nevabereki theme misikidzo. Mumwe wevatinoshanda navo paElvenated Marketing Solutions akabvunza kana tichigona kuita chiitiko chekutevera pane mabhatani sezvo iwo aive makuru ekudaidzira-kuzviito munzvimbo dzese. Shortcode mabhatani hapana chimwe kunze kweiyo anchor tag iyo yakagadzirirwa zvishoma zvinonzwisisika vachishandisa akateedzana emakirasi ayo anogarwa nesarudzo pfupi nzira.

Nekuda kweizvi, isu taida kuwedzera onclick chiitiko kune anchor zvinyorwa kuti tinyore chiitiko. Hezvino izvo zvinogona kutaridzika.

Bhatani repamba

Dambudziko, hongu, nderekuti pane ipfupi kodhi mune yedu dingindira remubereki uye hatidi kugadzirisa theme yemubereki. Uye, sezvo shortcode ichiiswa pane zvese zvirimo pasiti, isuwo hatidi kugadzira shortcode nyowani.

Mhinduro yacho yakanaka kwazvo. Iyo WordPress API inokutendera kuti ubvise ipfupi! Saka, mune yedu theme yemwana, tinogona kubvisa iyo shortcode, tobva tatsiva needu nyowani shortcode basa:

add_action ('after_setup_theme', 'kudaidza_mwana_uye_setup');
basa kudana_child_theme_setup () {remove_shortcode ('old_button_function_in_parent_theme'); add_shortcode ('bhatani', 'new_button_function_in_child_theme'); }
shanda new_button_function_in_child_theme ($ atts, $ zvemukati = null) {... shortcode yako nyowani iri pano ...}

Mune yangu nyowani bhatani basa (mune yangu YeMwana Dingindira function.php), ini ndakanyorazve iyo shortcode basa kuisidzira ine simba chiitiko paClick chiitiko. Zvinobuda zvinoshanda zvakanaka uye izvozvi zviri kuteedzera muGoogle Analytics!

Unofungei?

Nzvimbo iyi inoshandisa Akismet kuderedza spam. Dzidza kuti sei deta yako inoshandiswa.