內容簡介
Insert Pages 可讓您使用 Shortcode API,將任何 WordPress 內容(例如,頁面、文章、自訂文章類型)嵌入其他 WordPress 內容。它還包括一個小工具,可將頁面插入到任何小工具區域。
當您開始創建自訂文章類型時,Insert Pages 的真正力量就發揮出來了,不論是在您的佈景主題中以編程方式創建,還是使用另一個插件,例如 Custom Post Type UI。您可以將常見的數據類型(例如視頻、測驗、截止日期)抽象成自己的自訂文章類型,然後通過插入短碼將這些內容顯示在正常頁面和文章中。
高級教程
Wes Modes 貢獻者慷慨地為古騰堡時代撰寫了更新的教程,重點是創建帶有自定義字段和自定義模板以呈現內容的自訂文章類型。在此處閱讀:https://medium.com/@wesmodes/using-wordpress-insert-pages-plugin-with-your-custom-post-types-and-custom-templates-535c141f9635。
範例:常規用例
假設您正在教授一門課程,並且在課程網站上不斷提及作業截止日期。下一學期截止日期更改了,您必須去更改所有參考的位置。相反,您希望只需更改一次日期!使用Insert Pages,您可以執行以下操作:
創建名為 Due Date 的自訂文章類型。
使用 Fri Nov 22, 2013 作為內容創建新的 Assignment 1 Due Date。
編輯所有出現截止日期的頁面,並使用插入頁面工具列按鈕插入對剛剛創建的 Due Date 的引用。請務必將 Display 設置為內容,以便 Fri Nov 22, 2013 在您插入它的任何地方顯示。您剛剛建立的短碼應該看起來像這樣:[insert page='assignment-1-due-date' display='content']。
這就是它!現在,當您要更改截止日期時,只需編輯您創建的 Assignment 1 Due Date 自定義文章,就會自動更新所有插入它的頁面上的日期。
範例:高級用例
假設您的網站有很多視頻內容,您想在顯示視頻的任何位置搭配顯示視頻講稿和視頻長度。您可以只將講稿貼在視頻下的頁面內容中,但這樣您必須在每個顯示該視頻的頁面上進行此操作。 (從架構上來說,這也只是一個壞主意!) 利用 Insert Pages,您可以使用自訂文章類型並創建自訂佈景主題模板,以想要的方式顯示視頻 + 講稿 + 長度!
創建名為 Video 的自訂文章類型。
使用像 Advanced Custom Fields 這樣的插件向您的新 Video 自訂文章類型添加額外的字段。添加Video URL字段,Transcript字段和Video Length字段。
創建一個名為 My Awesome Video 的新 Video,將以下值添加到其字段中:
Video URL: http://www.youtube.com/watch?v=oHg5SJYRHA0
Transcript: We're no strangers to love, You know the rules and so do I…
Video Length: 3:34
在您的佈景主題中創建一個模板,以便我們可以按照所需的方式顯示視頻內容。我不會在此處涵蓋此步驟,因為它相當複雜,但您可以在 WordPress Codex 中找到更多幫助:https://codex.wordpress.org/Theme_Development#Custom_Page_Templates。 假設您創建了
外掛標籤
開發者團隊
📦 歷史版本下載
原文外掛簡介
Insert Pages lets you embed any WordPress content (e.g., pages, posts, custom post types) into other WordPress content using the Shortcode API. It also includes a widget for inserting pages into any widget area.
The real power of Insert Pages comes when you start creating custom post types, either programmatically in your theme, or using another plugin like Custom Post Type UI. You can then abstract away common data types (like videos, quizzes, due dates) into their own custom post types, and then show those pieces of content within your normal pages and posts by Inserting them as a shortcode.
Advanced Tutorial
Contributor Wes Modes has graciously written an updated tutorial for the Gutenberg era, focused on creating a custom post type with custom fields and a custom template for rendering content. Read it here: https://medium.com/@wesmodes/using-wordpress-insert-pages-plugin-with-your-custom-post-types-and-custom-templates-535c141f9635
Example: Normal Use Case
Say you teach a course and you’re constantly referring to an assignment due date in your course website. The next semester the due date changes, and you have to go change all of the locations you referred to it. Instead, you’d rather just change the date once! With Insert Pages, you can do the following:
Create a custom post type called Due Date.
Create a new Due Date called Assignment 1 Due Date with Fri Nov 22, 2013 as its content.
Edit all the pages where the due date occurs and use the Insert Pages toolbar button to insert a reference to the Due Date you just created. Be sure to set the Display to Content so Fri Nov 22, 2013 shows wherever you insert it. The shortcode you just created should look something like this: [insert page='assignment-1-due-date' display='content']
That’s it! Now, when you want to change the due date, just edit the Assignment 1 Due Date custom post you created, and it will automatically be updated on all the pages you inserted it on.
Example: Advanced Use Case
Say your site has a lot of video content, and you want to include video transcripts and video lengths along with the videos wherever you show them. You could just paste the transcripts into the page content under the video, but then you’d have to do this on every page the video showed on. (It’s also just a bad idea, architecturally!) With Insert Pages, you can use a custom post type and create a custom theme template to display your videos+transcripts+lengths just the way you want!
Create a custom post type called Video.
Use a plugin like Advanced Custom Fields to add extra fields to your new Video custom post type. Add a Video URL field, a Transcript field, and a Video Length field.
Create a new Video called My Awesome Video with the following values in its fields:
Video URL: http://www.youtube.com/watch?v=oHg5SJYRHA0
Transcript: We’re no strangers to love, You know the rules and so do I…
Video Length: 3:34
Create a template in your theme so we can display the video content as we want. I won’t cover this step here since it’s pretty involved, but you can find more help in the WordPress Codex. Let’s assume you created a template called Video with transcript (video-with-transcript.php) that shows the youtube video in a fancybox, and includes a button that shows the text transcript when a user clicks on it.
Edit the pages where you want the video to show up and use the Insert Pages toolbar button to insert a reference to the Video you just created. Be sure to set the Display to Use a custom template, and select your new template Video with transcript. The shortcode you just created should look something like this: [insert page='my-awesome-video' display='video-with-transcript.php']
That’s it! Now you can create all sorts of video content and know that it’s being tracked cleanly in the database as its own custom post type, and you can place videos all over your site and not worry about lots of duplicate content.
The possibilities are endless!
