[WordPress] 外掛分享: Custom Post Type Template Redirect

首頁外掛目錄 › Custom Post Type Template Redirect
20+
安裝啟用
尚無評分
5700 天前
最後更新
問題解決
WordPress 3.0+ v1.0 上架:2010-08-10

內容簡介

WordPress 自訂文章類型的一個缺點就是無法輕易地設置與標準的 single.php 不同的自訂樣板。如果是一個自訂文章類型,它有自訂資訊,我想把它放在自訂樣板中!

因此我製作了一個外掛來處理這個問題。安裝並啟用此外掛后,它會在您的樣板目錄中查找 posttype.php,然後是 t_posttype.php。如果這兩個文件都不存在,那麼標準的 WordPress 樣板規則將生效。

例如,如果您的自訂文章類型是“books”,它會在您的樣板目錄中查找“books.php”。如果找到了,它就會將其用作您的“books”文章的樣板。如果沒有找到,它就會查找“t_books.php”,並將其用作您的“books”文章的樣板。如果都沒有找到,標準的 WordPress邏輯就會生效,查看您是否為該文章定義了一個樣板,如果沒有,則使用 single.php。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Custom Post Type Template Redirect」→ 直接安裝(推薦)

原文外掛簡介

One of the shortcomings of Custom Post Types in WordPress is that there’s no way to easily set a different custom template from the standard single.php. If it’s a custom post type, it’s got custom information, and I want to put it in a custom template!
So I threw together a plugin to handle this. With this plugin installed and activated, it checks your template directory for posttype.php then t_posttype.php. If neither exists, then the standard WP template rules take effect.
For example, if your custom post type is ‘books’, it’s going to check your template directory for ‘books.php’. If it finds it, it will use that as the template for your ‘books’ posts. If not, it will check for ‘t_books.php’, and use that as the template for your ‘books’ posts. If it finds neither, the standard WP logic kicks into place, looking to see if you’ve defined a template for the post, and, if not, using single.php.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon