如何在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/

WordPress在不同分類使用不同主題的方式

在 WordPress 中, 使用佈景主題令人賞心悅目, 不過想要在不同分類頁面下, 使用不同的主題, 如何進行呢? 可以參考這篇文章中的說明:

http://codex.wordpress.org/Category_Templates

在 WordPress 的程式中, 佈景主題使用的頁面, 依序為:

  1. category-slug.php (於2.9版起才支援)
  2. category-ID.php
  3. category.php
  4. archive.php
  5. index.php

而整個 Template 的架構可以參考這張圖比較清楚:

http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

如此一來, 若是想要自行設計調整在分類(Category)頁下使用不同的主題, 就可以在對應的分類實施, 以達成更豐富的呈現效果.