Sengoli sa Lingoloa
U ka etsa shortcode joang ho bonts'a tlhaloso ea sehlopha?
Ka mohlala, nahana ka setšoantšo se ka tlaseWordpressTlhaloso ea sehlopha, e hlahang leqepheng le boletsoeng:
U ka etsa shortcode ea WordPress joang ho fumana setšoantšo se hlalositsoeng sa setšoantšo sa sehlopha?
A re re u batla ho khona ho hlahisa litlhaloso tse itseng tsa likarolo le lihlahisoa (WooCommerce) maqepheng kapa liphatlalatsong ka li-shortcode, empa ha u tsebe ho etsa shortcode ea WordPress e bonolo u sebelisa khoutu.
Ka kopo, kenya khoutu e latelang faeleng ea function.php:
//WordPress简码获取指定分类目录图像描述显示
add_shortcode('cat_description', 'my_cat_description_shortcode'); function my_cat_description_shortcode($atts){ $a = shortcode_atts( array( 'id' => 0, ), $atts ); return category_description($a['id']); }
Haeba u batla ho letsetsa shortcode ea WordPress ho tloha template (ho sa hlokahale ntle le haeba u eketsa litaba tse ling ho shortcode) u ka sebelisa khoutu ena:
<?php echo do_shortcode(''); ?>
- har'a bona
category_id
ke ID ea sehlopha.
U ka fumana pontšo ea tlhaloso ea sehlopha sa hajoale ea WordPress joang leqepheng la sengoloa se boletsoeng ka WP shortcode?
Ho bonts'a tlhaloso ea sehlopha leqepheng le boletsoeng, eketsa shortcode e latelang ea WordPress:
- Haeba matšoao a quotation sehlopheng sa tlhaloso ea shortcode id a siiloe a se na letho, o ka letsetsa setšoantšo sa hona joale sa tlhaloso ea sehlopha sa WordPress ka ho toba.
Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) o arolelane "Joang ho etsa shortcode ea WordPress ho fumana pontšo ea tlhaloso ea setšoantšo sa sehlopha se boletsoeng?", E leng thuso ho uena.
Rea u amohela ho arolelana sehokelo sa sengoloa sena:https://www.chenweiliang.com/cwl-20133.html
Rea u amohela ho mocha oa Telegraph oa blog ea Chen Weiliang ho fumana lintlha tsa morao-rao!
📚 Tataiso ena e na le boleng bo boholo, 🌟Ona ke monyetla o sa tloaelehang, se ke oa o fetoa! ⏰⌛💨
Share le rata haeba u rata!
Ho arolelana le lintho tseo u li ratang ke khothatso ea rona e tsoelang pele!