[WordPress] 外掛分享: Template Map

WordPress 外掛 Template Map 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Template Map」是 2014-07-17 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2022-02-10,距離現在已有 1179 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.9 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

jchristopher |

外掛標籤

link | template |

內容簡介

Template Map 是一個實用外掛,旨在讓你更輕鬆地建立和管理自定主題中的導覽元素。它摒棄了在全局和頁首導覽系統中(如果你選擇不使用菜單)硬編碼文章 ID 等必須嵌入代碼的需求。

例如

很多時候,你也許會使用以下代碼來建立主網站導覽:

這在最初開發期間很有效,且當你一次性地遷移至生產環境時仍然保持穩定。但是,當你正在進行後續更新時,開發環境中的文章 ID 與生產環境中的不同,這怎麼辦呢?你或許可以花時間每次同步資料庫,但這有點矯枉過正。這就是 Template Map 起作用的地方:

Template Map 允許你基於所指定的頁面模板動態地取得你想要的文章 ID。頁面模板檔名很少(或從來沒有)變更,因此這是 Template Map 實現的核心概念。一切都是由它開始運作的。

當然,這個方法假定你的頁面模板只使用一次,這點要記在心裡。現代客戶網站通常為每個網站部分的「父級」頁面使用唯一的頁面模板。

目前網站部分

Template Map 還可以更輕鬆地判定當前頁面是否位於網站「部分」內。其中,部分定義為具有任意子頁面和/或自訂文章類型的唯一頁面模板的頂層頁面。當你嘗試在導覽中設置「當前」狀態時,這非常有用,例如:

基於同樣的原則,你可以使用此實用方法在當前頁面與網站「部分」之間條件地加載類別。

原文外掛簡介

Template Map is a utility plugin designed to make the creation and management of navigation elements in your custom theme that much easier. It abstracts the need to hard code post IDs and the like from your global and header navigation systems (if you choose to not use Menus) for instance.
For Example
Many times you may use something like the following to build your main site navigation:

That works great during initial development, and continues to hold up when you migrate to production en masse for the first time. But what about when you’re making subsequent updates and the post IDs in your development environment are different than those in production? You could take the time to sync the databases each and every time, but that’s a bit overkill. Here’s where Template Map comes in to play:

Template Map allows you to dynamically retreive your desired post ID based on the Page Template you told it to use. Page Template filenames rarely (if ever) change, so it’s the core concept of Template Map’s implementation. Everything works backwards from here.
Naturally this philosophy assumes your Page Template is used only once, it’s important to keep that in mind. Modern client sites often use unique Page Templates for the ‘parent’ pages of each site section.
Current Site Section
Template Map also makes it easier to determine whether the current page is within a site ‘section’ which is defined as a top level Page with a unique Page Template that has any number of child Pages and/or Custom Post Types within it. This is very useful when trying to set a ‘current’ state in your navigation, for example:

Based on the same principle you can use this utility method to properly orient yourself when outputting conditional classes contingent on the current page being within a ‘secton’ on your site.

各版本下載點

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

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


1.0 | 1.0.1 | trunk |

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

  • Page Links To 》這個外掛可以讓你將 WordPress 的頁面(或文章或自訂文章類型)連結至你選擇的 URL,而非 WordPress 的 URL。此外,它還會將前往舊的 URL(或「正常」的 URL...。
  • Custom Post Type Permalinks 》自訂文章類型永久連結允許您編輯自訂文章類型的永久連結結構。, 更改自訂分類目錄的永久鏈接,以“example.org/post_type/taxonomy_name/term_slug̶...。
  • Custom Permalinks 》name or slug), add the filter that looks like this:, function yasglobal_exclude_posts( $post ) {, // Replace '2' with ID of the post you want to ...。
  • VK Link Target Controller 》外掛介紹, VK Link Target Controller 外掛可在最近文章列表或存檔頁面中,讓使用者點選文章標題時轉址到其他網頁而非文章內容頁面。, 使用範例, 假設你在 eB...。
  • Title and Nofollow For Links (Classic Editor) 》這個外掛程式在插入連結彈出框中恢復了 WordPress 4.2 中刪除的「Title」欄位,並新增了一個「將連結加上 rel="nofollow"」的勾選框。, Gutengerg(區塊編輯...。
  • Flexy Breadcrumb 》PressTigers 的 Flexy Breadcrumb 是一個簡單而強大的麵包屑導覽系統外掛,適用於 WordPress 網站。使用此外掛,您可以透過 [flexy_breadcrumb] 短碼在網站的...。
  • Nofollow for external link 》這個外掛可以自動為您網站文章、頁面或主題菜單中所有外部連結插入 rel=nofollow 和 target=_blank。, 您也可以設置要排除的域名,選擇不為特定外部連結添加 ...。
  • Link Library 》此外掛用於在您的網站上建立一個頁面,列出 WordPress 管理介面內的 "連結" 部分中所定義的所有連結分類及其內所包含的所有連結。使用者可以選擇是否顯示某些...。
  • Link Juice Keeper 》錯誤 404 ( 找不到頁面 ) 很常見,也是造成搜尋引擎,例如 Google,把網站排名降低的主要原因之一。處理 404 錯誤對於非技術人員來說可能相當複雜。有了這個...。
  • rus to lat advanced 》這款 WordPress 外掛將俄文標題的文件名和連結(從標題中建立)轉換為拉丁字母。俄文標題的文件名和連結在 WordPress 中儲存時經常是不正確的。, 例如,在標...。
  • Custom Meta Widget 》這個外掛的功能和 WordPress 標準的 Meta widget 完全相同,除了它增加了選項來控制要顯示哪些 5 個標準的 Meta widget 連結,並提供一個新增自訂連結的選項...。
  • Autologin Links 》這個外掛讓管理員可以為其 WordPress 網站生成自動登入連結,並以特定使用者名稱登入訪客。管理員可以編輯(生成和刪除)使用者的自動登入連結,而使用者只能...。
  • Track The Click 》追踪點擊次數, Track The Click 外掛能夠幫助網站擁有者更好地了解網站訪客與網站上連結的互動情形。這款外掛主要功能是即時追踪 WordPress 網站上發生的點擊...。
  • Sape – website monetization 》這個外掛程式能夠自動將 Sape 系統的程式碼安裝到網站上。, 這是一個從 Sape 取得利益的網站收益外掛程式。此外掛支援以下的網站收益方式:, , 租借連結, 全...。
  • Ambrosite Next/Previous Post Link Plus 》重要提示:請確保使用正確的外掛程式。, , Next/Previous Post Link Plus 外掛程式適用於單篇文章模板。, Next/Previous Page Link Plus 外掛程式適用於頁面...。

文章
Filter
Apply Filters
Mastodon