前言介紹
- 這款 WordPress 外掛「Dynamic Template Parts」是 2024-12-02 上架。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2024-12-03,距離現在已有 151 天。
- 外掛最低要求 WordPress 5.8 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 7.4 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
block | editor | switcher | template | custom templates |
內容簡介
總結:使用動態模板部件來管理 WordPress 網站的模板,這個強大的外掛擴展了全站編輯器,讓您根據您正在編輯的內容動態交換標頭、頁腳和其他模板部件 - 不再需要為每個佈局變化管理多個模板。
問題:Dynamic Template Parts 這個外掛的主要特點有哪些?
- 動態模板部件交換:在區塊編輯器中替換標頭、頁腳、側欄或任何模板部件。
- 靈活的交換選項:定義是否要在相同類型、任何類型或特選部件之間進行交換。
- 模板部件預覽:在選擇之前預覽模板部件,確保您的內容看起來完美。
- 支援所有內容類型:適用於文章、頁面和自定義文章類型。
- 用戶友好界面:簡單設置-無需編程。
原文外掛簡介
Transform the way you manage templates on your WordPress site with Dynamic Template Parts. This powerful plugin extends the Full Site Editor, letting you swap headers, footers, and other Template Parts dynamically based on the content you’re editing — say goodbye to managing multiple templates for every layout variation.
With Dynamic Template Parts, you gain the freedom to swap Template Parts directly within the block editor, whether it’s for posts, pages, or custom post types. The user-friendly interface allows you to preview changes in real-time, giving you complete control over the look and feel of each piece of content without needing custom code.
Key Features:
Dynamic Template Part Swapping: Replace headers, footers, sidebars, or any template part within the block editor.
Flexible Swapping Options: Define whether to swap within the same type, any type, or curated parts.
Template Part Previews: Preview Template Parts before selecting, ensuring your content looks perfect.
Supports All Content Types: Works with posts, pages, and custom post types.
User-Friendly Interface: Simple setup—no coding required.”
Get Started:
To implement an alternative Header Template Part using the Full Site Editor, please follow the example workflow below:
Create an Alternative Header Template Part: Design and save a new Header Template Part within the Full Site Editor to serve as an alternative to your default header.
Edit the Single Posts Template: Navigate to the Single Posts template and select the Header Template Part, and view the block sidebar.
Enable the Dynamic Template Part Option: In the Template Part attributes panel, enable the Dynamic Template Part setting.
Configure Swapping Preferences (Optional): Adjust your swapping preferences according to your requirements (choose to swap your Template Part with differnt Template Part types, or use a curated list of Template Parts).
Edit a Post and Access the Dynamic Template Part Sidebar: Open a post for editing and select the Dynamic Template Part sidebar from the editor interface.
Select the Alternative Header Template Part: Choose the alternative Header Template Part you created to replace the default header in this specific post.
Save and Preview the Post: Save your changes and preview the post to verify that the alternative header is displayed correctly.
Confirm Default Header on Other Posts: Ensure that all other posts without specific configurations continue to display the default header as intended.
Unlock the power of dynamic templating and take control of your site’s design like never before!
Hooks and Filters
Dynamic Template Parts provides filters to allow developers to customise its behaviour. Below are the available filters and how to use them.
Show Deselected Template Part
The dynamic_template_parts_show_deselected_template_part filter lets you control whether a previously selected template part that is no longer available for selection should still be displayed. By default, the plugin keeps the part visible to avoid unintended changes, but you can override this to automatically remove unavailable template parts.
Example:
If you want to ensure that unavailable template parts are removed and replaced with the default template part, you can use the following code:
add_filter( 'dynamic_template_parts_show_deselected_template_part', function( $show_deselected, $template_parts, $selected_part ) {
// Always hide deselected template parts and fall back to the default.
return false;
}, 10, 3 );
Parameters:
$show_deselected (bool): Whether to show the deselected template part. Defaults to true.
$template_parts (array): The list of available template parts.
$selected_part (string): The currently selected template part.
User Permissions
The dynamic_template_parts_user_can_switch filter lets you customise which users are allowed to switch template parts. By default, any user with the edit_posts capability can access this functionality, but you can restrict it to specific roles or capabilities.
Example:
If you want to restrict template part switching to administrators only, you can use the following code:
add_filter( 'dynamic_template_parts_user_can_switch', function( $can_switch ) {
// Allow only administrators to switch template parts.
return current_user_can( 'manage_options' );
} );
Parameters:
$can_switch (bool): Whether the current user has permission to switch template parts. Defaults to checking the edit_posts capability.
Roadmap
Support for additional content types: Support additional content types such as authors, terms and archive pages.
Requirements
WordPress version 5.8 or higher.
PHP version 7.4 or higher.
Known Issues
See the Roadmap section for known issues.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Dynamic Template Parts」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Custom post types, Custom Fields & more 》確實免費的 WordPress 外掛「自訂型態文章」可以讓您:, , 建立自訂型態文章, 建立自訂分類(例如:類別、標籤等等), 在型態文章上建立自訂欄位, 在分類上建...。
Login Page Customizer – Customizer Login Page, Admin Page, Custom Design 》自定義登錄頁面外掛可以讓您在登錄頁面上即時查看所有更改,並非常輕鬆地編輯它們。您可以在WordPress管理員登錄頁面上做出很多更改,如自定義登錄頁面標誌、...。
WP Page Templates 》, , 輕鬆為任何佈景主題創建自訂頁面模板。, , , 想要使用一個沒有全寬頁面模板的 WordPress 主題?使用 WP Page Templates,將任何模板添加到您的主題上。, ...。
Hide Header on Posts for Landing Pages 》, , 輕鬆將文章轉換為落地頁面, , , 在單篇文章頁面上隱藏標題, , , 在查看文章時移除標誌、菜單和整個頁面頂部, , , 無需代碼。只需在創建文章時啟用該選項...。
Custom HTML/PHP Post Templates 》這個外掛讓你可以使用任何 HTML 或 PHP 檔案作為任何頁面或文章的模板。, 只需要上傳檔案並選擇它即可。, 你可以將自定義的 js 和 css 檔案上傳到媒體庫並從 ...。
WooCommerce Product Page Templates 》, , 輕鬆建立 WooCommerce 產品的自訂頁面模板, , , 將產品頁面轉換為落地頁面, , , 想在產品頁面上添加左側或右側的側邊欄?這個外掛可以讓操作變得簡單。, ...。
WooCommerce Simple Frontend Manager 》從前端查看、編輯和創建 WooCommerce 產品, 你的 WooCommerce 商店是由其他人管理的嗎?也許你為客戶建立商店,, 或你的商店由員工或承包商管理, 或你想讓你...。
Ultimate Post Types 》Ultimate Post Types 為使用者提供一個易於管理自訂文章類型和分類法的介面。它完全使用 WordPress 文章類型和分類法 API 並涵蓋了建立文章類型、新增分類法...。
Taxonomy Templates 》Taxonomy Templates 外掛可以讓使用者像在設定頁面的選擇模板一樣,在可用的分類模板中選擇模板。, 當有更多的模板可用時,在編輯分類、標籤和任何自訂分類頁...。
Quick Location Maps 》這個外掛插入地圖至您的文章/頁面,使用基於 iFrame 的 Google Maps,無需任何 API。, 使用者可以設定精確的座標(緯度或經度)或輸入地址。若您想在文章中插...。
Custom-Single 》此外掛讓佈景主題能夠根據文章分類指定不同的single.php範本。由於文章可以有多個分類,因此它使用以下方式選擇可能的自訂範本:, 1)直接分配分類, R...。