如何在wordpress theme中使用short code

在 wordpress 的 theme 中, 若想使用一些原本在 page 或 post 中的外掛 shortcode , 要如何使用呢?

只需要在 theme 的程式碼中使用 do_shortcode 函式即可, 如下:
[code]
echo do_shortcode(“[example_shortcode]”);
[/code]

如此一來便能在 wordpress theme 中使用 shortcode 了.

參考資料:

http://www.wpbeginner.com/wp-themes/how-to-use-shortcodes-in-your-wordpress-themes/

http://www.wpbeginner.com/wp-tutorials/how-to-add-a-shortcode-in-wordpress/

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *