內容簡介
這個簡單而強大的外掛是為了插件開發人員而寫的,它允許您使用短碼運行自定義 WP_Query,然後使用相容的嵌套短碼以任何想象的方式顯示結果。
使用方式
將以下短碼添加到任何 WordPress 文章或頁面中:
[wpquery orderby="rand"] [wpq_index] [/wpquery]
在上面的示例中,[wpquery] 短碼使用 orderby=”rand” 執行 WP_Query,以隨機順序顯示結果。可以在這裡找到所有的查詢參數列表:WP_Query。
接下來,嵌套的 [wpq_index] 短碼以無序列表的形式顯示自定義 WP_Query 的結果。
特點
這個簡單而強大的外掛是為了插件開發人員而寫的,它允許開發人員撰寫相容的插件,以操作文章數據的顯示方式,而不需要先撰寫函數和短碼參數來檢索文章數據。
此插件中包含的 [wpq_index] 短碼功能只是其能做的簡單例子。任何執行 WP_Query 的插件都可以重寫和優化以適應此外掛,從而消除許多不必要的代碼。
最棒的是,這個外掛允許用戶完全控制執行的 WP_Query!
外掛標籤
開發者團隊
原文外掛簡介
Written as a platform for plugin developers, this simple-yet-powerful plugin allows you to run a custom WP_Query using shortcode, then display the results any way imaginable using compatible nested shortcodes.
How It Works
Add the following shortcode to any WordPress post or page:
[wpquery orderby="rand"] [wpq_index] [/wpquery]
In the example above, the [wpquery] shortcode performs a WP_Query using orderby=”rand” to display the results in random order. A full list of query parameters can be found here: WP_Query.
Next, the nested [wpq_index] shortcode displays the results of the custom WP_Query as an unordered list of post title links.
Why It Rocks
Written as a platform for plugin developers, this simple-yet-powerful plugin allows developers to write compatible plugins that manipulate the way post data is displayed – without needing to write functions and shortcode parameters to first retrieve the post data.
The [wpq_index] shortcode function included in this plugin is just a simple example of what it can do. Any plugin that performs a WP_Query could be rewrtitten and optimized to work with this plugin, eliminating a lot of unnecessary code.
Best of all, this plugin gives users total control over the WP_Query being performed!
