WordPress主題製作

https://codex.wordpress.org/zh-tw:%E4%B8%BB%E9%A1%8C%E9%96%8B%E7%99%BC

WordPress主題解析

https://yoast.com/wordpress-theme-anatomy/

WordPress 主題放在 wp-content/themes/ 。主題的子資料夾中包含了主題的樣式表檔案、範本檔,以及選擇性功能檔案(functions.php) 、JavaScript 檔案以及圖片。例如:一個名叫「taiwan」的主題會放在 wp-content/themes/taiwan/ 資料夾中。請避免使用數字來為主題命名,因為這可能會導致該主題不在可用主題列表中顯示。

新安裝的 WordPress 包含了預設的主題。請仔細看一下預設主題中檔案,這樣您才會更加瞭解如何建立您自己的主題。

樣式表標頭

/*
Theme Name: Twenty Thirteen
Theme URI: http://wordpress.org/themes/twentythirteen
Author: the WordPress team
Author URI: http://wordpress.org/
Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of post formats, each displayed beautifully in their own unique way. Design details abound, starting with a vibrant color scheme and matching header images, beautiful typography and icons, and a flexible layout that looks great on any device, big or small.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: twentythirteen

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

範本檔清單

  1. Head 檔(header.php)
  2. 導航菜單 (header.php)
  3. 小工具 (sidebar.php)
  4. 頁面底部 (footer.php)
  5. 索引 (index.php)
  6. 歸檔 (archive.php)
  7. 頁面 (page.php)
  8. 日誌單獨頁面 (single.php)
  9. 評論 (comments.php)
  10. 搜索 (search.php)

add_action()

add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )

Hooks a function on to a specific action.

Tag
after_setup_theme
wp_enqueue_scripts
wp_footer
wp_head
init

results matching ""

    No results matching ""