前言介紹
- 這款 WordPress 外掛「Inject Query Posts」是 2010-09-26 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2025-04-23,距離現在已有 11 天。
- 外掛最低要求 WordPress 3.6 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
loop | posts | query | wp_query | template tags |
內容簡介
這個外掛提供一個函數供開發人員使用,他們自己有一些程式碼可以根據特定條件獲取文章,並現在想要利用具有迴圈能力的模板標籤顯示這些文章。
WordPress 的模板標籤旨在在「迴圈」中使用。迴圈由一個 WP_Query 物件管理,該物件設置了各種全局變數和其自身的物件變數,供各種模板標籤使用。 WP_Query 物件的主要目的是實際查詢符合當前指定條件的文章。但是,如果您不需要查詢文章,因為您已經以其他方式獲取了它們,仍然可以通過此插件將這些文章注入到 WP_Query 中,以便利用模板標籤。
根據您要使用的模板標籤或您希望在迴圈中使用的邏輯,您可能需要手動配置一些查詢物件的變數。
示例:
// 我們自己獲取了一些文章物件。
$posts = c2c_get_random_posts( 5, '' );
// 將文章注入
c2c_inject_query_posts( $posts );
// 現在讓我們透過模板標籤來顯示這些文章:
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
連結: 外掛主頁 | 外掛目錄頁面 | GitHub | 作者主頁
開發人員文件
開發人員文件可在DEVELOPER-DOCS.md 中找到。該文件介紹了此外掛提供的模板標籤和鉤子。
概述來說,此外掛提供了以下模板標籤:
c2c_inject_query_posts() :模板標籤,可以像查詢物件一樣將一組文章注入到查詢物件中。
此外,此外掛提供了以下鉤子:
inject_query_posts_preserve_query_obj:覆蓋傳遞給函數的 $preserve_query_obj 參數的值。對於大多數用戶來說,這不是典型用法。
c2c_inject_query_posts :允許使用替代方法安全調用 c2c_inject_query_posts(),這樣如果外掛被停用或刪除,則調用該函數不會在您的網站上引起錯誤。
原文外掛簡介
This plugin provides a function for use by developers who have their own code for fetching posts according to a given criteria and now want to make use of loop-aware template tags to display those posts.
WordPress’s template tags are intended to be used within ‘the loop’. The loop is managed by a WP_Query object which sets up various global variables and its own object variables for use by the various template tags. The primary purpose of a WP_Query object is to actually query the database for the posts that match the currently specified criteria. However, if you don’t need to query for posts since you already have them by some other means, you can still take advantage of the template tags by injecting those posts into the WP_Query via this plugin.
Depending on the template tags you are looking to use, or the logic you are hoping to employ within a loop, you may need to manually configure some of the query object’s variables.
Example:
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer Documentation
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the template tag and hooks provided by the plugin.
As an overview, this is the template tag provided by the plugin:
c2c_inject_query_posts() : Template tag to inject an array of posts into a query object as if that query object had obtained those posts via a query.
These are the hooks provided by the plugin:
inject_query_posts_preserve_query_obj : Overrides the value of the $preserve_query_obj argument passed to the function. This is not typical usage for most users.
c2c_inject_query_posts : Allows use of an alternative approach to safely invoke c2c_inject_query_posts() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Inject Query Posts」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
2.0 | 2.1 | 2.2 | 3.0 | 2.0.1 | 2.0.2 | 2.0.3 | 2.0.4 | 2.0.5 | 2.2.1 | 2.2.2 | 2.2.3 | 2.2.4 | 2.2.5 | 2.2.6 | 2.2.7 | 2.2.8 | 2.2.9 | 3.0.1 | 3.0.2 | 3.0.3 | 3.0.4 | 3.0.5 | trunk |
延伸相關外掛(你可能也想知道)
Elementor Custom Skin 》此外掛程式可向 Elementor 頁面建構器的文章和文章總覽 widget 添加新的佈景主題。, 您可以像單個模板一樣設計循環項目,並將其用作佈景主題,以便您可以按照...。
Custom Content Shortcode 》停用通知, , 此外掛已不再維護。, 請改使用下一代範本系統:Loops & Logic。, 概述, , 從單一欄位到整個頁面,Custom Content Shortcode 是一套指令,可...。
Loops & Logic 》Facebook group | homepage| docs |official support forum, Loops & Logic 是一個工具集,讓你可以對 WordPress 內容和數據在網站前端進行廣泛的控制,...。
Genesis Grid 》Genesis Grid 外掛的設計目的在於讓 Genesis 主題的使用者可以輕鬆地以網格格式顯示他們的文章。, 「特色文章」是列表頂部的全寬文章,而「概要」是分成多欄...。
Archivist – Custom Archive Templates 》快速入門, 此外掛程式假設您的文章已經有良好的分類。, 使用快捷碼在頁面或文章的任何位置顯示存檔。, [archivist category="kitten"], [archivist tag="kitt...。
WP Query Creator 》這個外掛讓你可以建立新的 WP 查詢,並在頁面上使用簡碼進行查詢。, WP 查詢建立器是最簡單的方法,可以在不寫一行程式碼的情況下建立 wp_query。, 有時當你...。
No Sub-Category Posts in Loops 》這個外掛啟用後,只會在迴圈中顯示當前分類的文章(不會顯示子分類中的文章)。, 這就是它的全部功能,沒有任何選項。如果您需要選項,請告訴我,我會加入進...。
Elevate Parent Category Template 》此外掛可提供函數來取得指定文章的母類別(父類別)資訊,若該文章被歸入於母類別的子類別中。, 透過這個功能,此外掛也能夠修改 WordPress 迴圈(Loop)並將...。
Custom Post Type Selector 》自定文章類型選擇器讓您可以選擇要包括在博客的主迴圈中的文章類型,包括自定文章類型。, 如果您覺得這個外掛有用,請捐贈給 Cancer Research UK,並透過我的...。
Easy 》Easy 是一個多功能的小工具,包含大部分常用於 WordPress 模板的原生功能。, 你可以將幾乎任何部分的內容放置在側邊欄的任何位置。, 此小工具由拖放建構而成...。
Wp Loop 》這個外掛會在你的 WordPress 網站上新增一個小工具,稱為「Wp Loop」,可以在需要的地方發佈此小工具並設定其選項,它會建立一個 WordPress 查詢循環,具有網...。
Post Category 》使用 The Loop 來顯示來自特定類別的文章。使用 The Loop,外掛處理每篇要在目前頁面顯示的文章,並根據匹配指定條件的方式進行格式化。, 您可以生成自己的短...。
mCatFilter 》mCatFilter 是一個 WordPress 外掛,允許您從首頁、rss 等存檔頁面中排除特定分類。, 關鍵特點, , 簡單易用的設置與配置, 不需要更改主題, 即使排除了分類,...。
Genesis Grid 》擴展 Genesis 網格至頁面模板。更多資訊即將推出…, 重要提示:, 您必須已安裝Genesis外掛,按此處了解更多:Genesis, 特別感謝, 我要向StudioPress的所...。
Widget Custom Loop 》這個小工具讓使用者可以建立自訂的迴圈。, 待辦事項, , 在迴圈前後新增短代碼, 。