前言介紹
- 這款 WordPress 外掛「Default Theme Pages」是 2012-06-17 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2012-08-30,距離現在已有 4629 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
block | pages | theme | templating |
內容簡介
此外掛旨在為模板開發人員提供便利
版本 0.4 中的新功能
在每個 $default_theme_pages 項目中添加「物件」(頁面物件),以便快速存取。
將所有預設頁面添加到 WordPress 工具列中「站台名稱」內,以增強使用者體驗。
使用方法
將下列程式碼加入 functions.php:
global $default_theme_pages;
$default_theme_pages = array(
array(
'name' => 'home', // 模板設置的初始頁面 slug / id - 存取函數
'title' => '首頁', // 頁面標題
'option' => 'page_on_front', // 選項頁面 ID(將頁面 ID 存儲在選項中,在這些情況下僅使用)
'description' => '首頁' // 描述
),
array(
'name' => 'blog',
'title' => '博客',
'option' => 'page_for_posts',
'description' => '博客'
),
array(
'name' => 'contact',
'title' => '聯絡我們',
'description' => '聯絡表單頁面'
)
);
提示
自動建立完頁面之後,您可以自由更改它們的標題和 slug。
若新增自訂頁面選項:「page_on_front」和「page_for_posts」,您將會阻止首頁和博客頁面。
模板設置
您可以依據 ID 或名稱(在 $default_theme_pages 全域變數中設置)進行模板設置,例如:
page-131.php 或 page-contact.php(如果您在 $default_theme_pages 全域變數中將其定義為 pagename,變更頁面 slug 後仍可正常運作)。
用以下程式碼偵測是否在該頁面:
dtp_is_page('contact')
取得預設頁面 ID:
$page_id = dtp_get_page_id('contact');
此方法較 get_page_by_path 更快,因為頁面 ID 儲存在全域變數中。
原文外掛簡介
This plugin is intended to be useful for template developers
New in version 0.4
added ‘object’ (page object) in every $default_theme_pages item for fast access.
added all default pages to wp toolbar, inside ‘site name’, to increase user experience.
How to use
Add this code in your functions.php.
global $default_theme_pages;
$default_theme_pages = array(
array(
'name' => 'home', // initial slug page / id for templating - access functions
'title' => 'Homepage', // page title
'option' => 'page_on_front', // option page id ( stores the page id in an option, use only in theese cases)
'description' => 'homepage' // description
),
array(
'name' => 'blog',
'title' => 'Blog',
'option' => 'page_for_posts',
'description' => 'blog'
),
array(
'name' => 'contact',
'title' => 'Contact me!',
'description' => 'Contact form page'
)
);
Tips
After the pages are created automatically, you can change their title and slug without problem.
If you add an option names: page_on_front and page_for_posts, you will block the home-page and the blog-page on your site.
Templating
You can template using ID or name (setted up in $default_theme_pages global variable ), something like:
page-131.php or page-contact.php (If you change the page slug, this will still work because ‘contact’ was defined as pagename if $default_theme_pages global variable).
For detect if you’re in that page:
dtp_is_page('contact')
Getting a default page id:
$page_id = dtp_get_page_id('contact');
This method is more quick than get_page_by_path because page ID is stored on global variable.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Default Theme Pages」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.2 |
延伸相關外掛(你可能也想知道)
Twigify 》這個外掛使用TWIG建立模板系統,您可以在WordPress管理介面中進行管理。不再需要為每個內容類型或上下文創建數十個模板文件。模板可以應用於每個頁面或文章,...。
Hatch 》Hatch 是一個協助開發人員建立網站的輔助程式庫,可以讓使用 Timber、Advanced Custom Fields Pro 及其他常用外掛更加愉悅。, 這是什麼東西?, Hatch 是一個...。
Action Runner by The Rite Sites 》隨著區塊的日漸普及,開發人員和商店所有者發現一些模板功能缺失,通常透過 PHP 和 WordPress Hooks 可以獲得。 WordPress 社區正在努力將 PHP 中的可擴展性...。