WordPress: Ngola Shortcode ho tsoa ho Sehlooho sa Batsoali ho Ngoana oa Hao Theme

WordPress API

E se e le nako e telele ho tloha ha ke arolelane malebela a ho etsa lenaneo ka WordPress. Morao tjena, ke khutletse bencheng ke romella khoutu bakeng sa bareki bohle ba rona mme ho bile monate ho khutlela linthong tsa lintho. Mohlomong u hlokometse likhokahano tse ncha tsa Papatso ea papatso ho pholletsa le sebaka sa marang-rang - e neng e le morero o monate!

Kajeno, ke ne ke na le bothata bo fapaneng. Boholo ba bareki ba rona ba na le likonopo tse kentsoeng tšebelisong ea li-shortcode tsa sehlooho sa motsoali. E mong oa balekane ba rona ho Elevated Marketing Solutions o ile a botsa hore na re ka latela liketsahalo ka har'a likonopo kaha e ne e le batho ba bangata ba bitsang liketso ho pholletsa le libaka tseo. Li-button tsa Shortcode ha se letho ho feta tag ea ankora e raliloeng hantle haholo ho sebelisa letoto la lihlopha tse nang le likhetho tsa shortcode.

Ka lebaka la sena, re ne re hloka ho eketsa ketsahalo ea onchick ho sengoloa sa ankora ho ngolisa ketsahalo. Mona ke kamoo e ka shebahalang kateng:

<a href="https://highbridgeconsultants.com" class="button blue medium" onClick="ga('romela', 'ketsahalo', 'konopo', 'Tobetsa', 'Home Button');">Konopo ea Lehae

Bothata, ehlile, ke hore ho na le shortcode e teng ho rona sehlooho sa motsoali mme ha re batle ho hlophisa sehlooho sa motsoali. Hape, kaha shortcode e sebelisoa hohle hohle setšeng, ha re batle ho theha shortcode e ncha.

Tharollo e boreleli haholo. Lentsoe la WordPress API e u lumella ho tlosa shortcode! Kahoo, ka sehlooho sa rona sa ngoana, re ka tlosa shortcode, ebe re e nkela sebaka ka mosebetsi oa rona o mocha oa shortcode:

add_action ('after_setup_theme', 'calling_child_theme_setup');
mosebetsi o bitsang_child_theme_setup () {tlosa_shortcode ('old_button_function_in_parent_theme'); add_shortcode ('konopo', 'new_button_function_in_child_theme'); }
sebetsa new_button_function_in_child_theme ($ atts, $ content = null) {... shortcode ea hau e ncha e teng mona ...}

Ts'ebetsong ea ka e ncha ea konopo (ho My Theme's works.php), ke ile ka ngola ts'ebetso ea shortcode ho kenya ketsahalo e matla ho ketsahalo ea Click. Litholoana li sebetsa hantle haholo 'me hona joale li latela Google Analytics!

U nahana eng?

Sebaka sena se sebelisa Akismet ho fokotsa spam. Ithute kamoo litlhaloso tsa hau li hlahang kateng.