WordPress 佈景 style.css

WordPress 佈景主題開發(一)

WordPress 佈景 style.css

在 style.css 中,可以在控制台設定 WordPress 佈景主題的各項資訊,如名稱、說明、作者、版號等等。

在 wp-content\themes\zenblog 目錄下建立 style.css 檔案,內容如下:

/*----------------------------------------------------------------------------
	Theme Name: ZenBlog
	Theme URI: https://bootstrapmade.com/demo/ZenBlog
	Author: PolinWEI 魏明盛
	Author URI: https://polinwei.com
	Description: Template for Blog - 波林工作站
	Version: 1.1
  Text Domain: zenblog
	Domain Path: /languages
	Tags: zenblog, PolinWEI
-----------------------------------------------------------------------------*/

這時候在控制台的佈景主題會出現 ZenBlog 的佈景訊息。

現在可以按啟用。當然,現在啟用網站會是一片空白,我們還沒有做頁面。不過,先來看一下上面的每一行的用意:

Theme Name: 佈景主題名稱
Theme URI: 佈景主題網址
Description: 佈景主題說明
Author: 佈景主題作者
Author URI: 佈景主題作者網站
Version: 佈景主題版本號
Tags: 佈景主題標籤
License: 佈景主題授權
License URI: 佈景主題授權書

此時會出現錯誤

找不到佈景主題範本。獨立佈景主題需要 templates/index.html 或 index.php 範本檔案。子佈景主題需要在 style.css 樣式表標頭的 [Template] 資料中指定正確上層佈景主題代稱。

佈景主題 index.php

將此佈景主題的截圖命名為:screenshot.png ,並新增檔案: index.php ,而 index.php 的內容可以先撰寫說明檔即可。

<?php
/**
 * 佈景主題的主檔: ZenBlog
 * The main template file for ZenBlog themes
 * Designed by <a href="https://bootstrapmade.com/">BootstrapMade</a> 程式撰寫 By <a href="https://polinwei.com/">PolinWEI</a>

就可以在 外觀 查看到此佈景主題完整的圖示與說明。

發佈留言

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