[WordPress] 外掛分享: Custom Post Template

前言介紹

  • 這款 WordPress 外掛「Custom Post Template」是 2008-11-26 上架。
  • 目前有 10000 個安裝啟用數。
  • 上一次更新是 2017-11-28,距離現在已有 2714 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.4 以上版本才可以安裝。
  • 有 43 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

simonwheatley |

外掛標籤

post | theme | template |

內容簡介

提供一個下拉式功能,讓您可以在文章編輯頁面中選擇不同的模板。這些模板和頁面模板類似,且會取代指定文章的 single.php。然而此外掛並不會在文章列表頁面(例如日期或類別檔案)上切換模板,僅會影響單獨文章的模板使用(也就是您可以選擇非 single.php 的模板)。

就此外掛而言,文章模板的設置方式和頁面模板類似,因為它們在頂部具有特定形式的 PHP 註解。每個文章模板必須包含以下或類似的設置:

/*
Template Name Posts: Snarfer
*/
?>

注意:頁面模板使用「Template Name:」,而文章模板使用「Template Name Posts:」。

注意:您必須將自訂文章模板檔案與 index.php 模板檔案置於同一個目錄/資料夾中,而不是在子目錄/子資料夾中。

開發者

如果您想要在自訂文章類型上實現自訂文章模板,您可以使用 cpt_post_types 過濾器。以下是一個範例,它顯示如何將自訂文章模板選擇器和元框架新增至「Movie」和「Actor」自訂文章類型中。此程式碼可新增至外掛或置於您的佈景主題中的 functions.php 檔案中。

/**
* 將 WP cpt_post_types 過濾器連接到函式
*
* @param array $post_types 這些模板所用的文章類型名稱陣列
* @return array這些模板所用的文章類型名稱陣列
**/
function my_cpt_post_types( $post_types ) {
$post_types[] = 'movie';
$post_types[] = 'actor';
return $post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );

原文外掛簡介

Provides a drop-down to select different templates for posts from the post edit screen. The templates are defined similarly to page templates, and will replace single.php for the specified post. This plugin will NOT switch the templates for the different posts in a listing page, e.g. a date or category archive, it will only affect the template used for single posts (i.e. you can choose a template which is not single.php).
Post templates, as far as this plugin is concerned, are configured similarly to page templates in that they have a particular style of PHP comment at the top of them. Each post template must contain the following, or similar, at the top:

First note: Page templates use “Template Name:“, whereas post templates use “Template Name Posts:“.
Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-directory/sub-folder.
Developers
If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here’s an example below of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types. This code can be added to a plugin or to the functions.php file in your theme.
/**
* Hooks the WP cpt_post_types filter
*
* @param array $post_types An array of post type names that the templates be used by
* @return array The array of post type names that the templates be used by
**/
function my_cpt_post_types( $post_types ) {
$post_types[] = 'movie';
$post_types[] = 'actor';
return $post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Custom Post Template」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 0.9b | 0.91b | 0.92b |

延伸相關外掛(你可能也想知道)

  • Kirki Customizer Framework 》 , 新增 -現在可使用 Kirki PRO , Kirki讓佈景主題開發者更快速、更輕鬆建立佈景主題。, Kirki 提供超過 30 個自訂控制,範圍從簡單的滑桿到具有 Google ...。
  • Child Theme Configurator 》res and options to help you take complete control of your WordPress site's visual appearance. With PRO, you can handle any plugin's CSS styles, pre...。
  • Easy Theme and Plugin Upgrades 》WordPress 具有透過提供壓縮檔案安裝主題和外掛的內置功能。不幸的是,您無法使用相同的過程升級主題或外掛。相反,當試圖使用壓縮檔案升級時,WordPress 會...。
  • Widget Shortcode 》這個短碼需要小工具的ID,但不需要猜測,外掛會為你生成代碼。如果你想要覆蓋小工具的標題,你可以使用 "title" 參數:, [widget id=”text-1″...。
  • All In One Favicon 》查看最新的WordPress交易以優化您的網站。, All In One Favicon為您的網站和管理頁面添加favicon。, 您可以使用您已經上傳的favicon或使用內置的上傳機制將fa...。
  • Theme Editor 》主題編輯器 (Theme Editor) 允許您編輯主題文件、建立資料夾、上傳檔案,以及在主題和外掛中移除任何檔案和資料夾。您可以直接自訂主題和外掛。, 升級至專業...。
  • Download Plugins and Themes in ZIP from Dashboard 》在儀表板下載外掛和佈景主題外掛可讓您直接從管理儀表板下載已安裝的外掛和佈景主題 ZIP 檔案而無需使用 FTP。, 外掛中沒有必須的設置 - 安裝後,所有以下 Do...。
  • Cryout Serious Theme Settings 》這個外掛是為了與我們的 Nirvana、Tempera、Parabola 和 Mantra 主題互相運作,並在目前的 WordPress 版本上啟用其進階設定頁面。, 相容性, 無論 WordPress ...。
  • WP Updates Notifier 》這個外掛程式會監控你的 WordPress 安裝,並會在核心、外掛程式和佈景主題更新時發送電子郵件通知你。如果你不經常登入 WordPress 管理員,或支援客戶的網站...。
  • Disable auto-update Email Notifications 》自 WordPress 5.5 起,若您已啟用外掛或佈景主題自動更新功能,當外掛或佈景主題自動更新成功或失敗時,您將會收到一封電子郵件通知。, 如果你管理多個網站,...。
  • WP Child Theme Generator 》WP子佈景主題產生器是一個非常簡單易用的外掛,可用於為WordPress CMS支援的任何佈景主題創建子佈景主題。使用多種選項創建子佈景主題,您可以輕鬆地創建和自...。
  • Multi Device Switcher 》Multi Device Switcher外掛允許您為設備(智能手機、平板電腦、手機、遊戲和自定義)設置單獨的佈景主題。, 此外掛可以偵測到使用者代理(UserAgent)是否正在...。
  • Multiple Themes 》重要提示:支援服務已移至 ZATZLabs 網站,不再於 WordPress.org 論壇提供。如需開發者迅速回覆,請提交請求單。, 此外掛設定提供多種選擇方式,可讓您選擇要...。
  • Disable All WordPress Updates 》這個外掛可以完全停用 WordPress 的主題、外掛和核心更新檢查系統。該插件防止 WordPress 檢查更新,包括 cronjobs,並防止顯示任何通知訊息。, 很重要的是,...。
  • WP-LESS 》LESS 是一種基於 CSS 的樣板語言。它提供了許多增強功能,以加速開發並使維護更容易。, 主題開發人員甚至可以捆綁該外掛而不用擔心衝突:只需包含特殊的 boot...。

文章
Filter
Apply Filters
Mastodon