[WordPress] 外掛分享: Super Recent Posts Widget

首頁外掛目錄 › Super Recent Posts Widget
WordPress 外掛 Super Recent Posts Widget 的封面圖片
50+
安裝啟用
★★★★★
5/5 分(2 則評價)
2249 天前
最後更新
問題解決
WordPress 3.6+ v0.3.0 上架:2014-01-22

內容簡介

拖曳小工具並填寫適當的欄位。一些注意事項:

若要顯示特定文章類型的文章,將「分類法」欄位留空設為“– 沒有特定的分類法 –“

如果讓「排序方式」和/或「排序依據」欄位設為“– 選擇排序參數 –”和/或「選擇 orderby 參數 – ”–,WordPress會使用預設設定,這裡有更多資訊。

以下過濾器是可用的:

srpw_get_args,用於覆寫小工具的主要查詢參數。
srpw_template,用於覆寫小工具的輸出範本,有關詳細說明請參閱下面。
srpw_WIDGET_NAME_template,用於覆寫按小工具設定的小工具輸出範本。WIDGET_NAME會在小工具窗口中的後端出現,有關詳細說明請參閱下面。
widget_title,這是 WordPress 核心過濾器,有關詳細資訊請參閱此處。
srpw_post_types,用於覆蓋此小工具可用的文章類型。
srpw_taxonomies,用於覆蓋此小工具可用分類法。

srpw_template過濾器的使用方法

在您的範本目錄中添加一個名為「views」的目錄,並添加一個名為「custom-srpw.php」的檔案。該「custom-srpw.php」檔案將是您此範本的自訂範本。

範例:使用自訂範本來源於您的主題,應用程式的 PHP 版本為 5.3 以前
<?php

function customize_srpw_template_filter( $template ){
$template_dir = get_template_directory();
return $template_dir . '/views/custom-srpw.php';
}
add_filter( 'srpw_template', 'customize_srpw_template_filter' );
?>

範例:使用自訂範本來源於您的主題,應用程式的 PHP 版本為 5.3 以後,可以使用匿名函數
<?php

add_filter( 'srpw_template', function ( $template ){
$template_dir = get_template_directory();
return $template_dir . '/views/custom-srpw.php';
} );
?>

Grunt

此外採用 Grunt 來驗證 JavaScript,SASS 編譯和縮減功能。如果要對此外掛進行編輯/派生,那麼使用 Grunt 可以大有幫助。要使用 Grunt,您必須安裝npm和Grunt。訪問各自的網站以確保已安裝。一旦安裝好,就可以使用這兩個工具。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.3.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Super Recent Posts Widget」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Drag and drop the widget and fill out the appropriate fields. Some notes:
To display posts from a specific post type leave Taxonomy as “– No Specific Taxonomy –“
If you leave order by and/or order as “– Choose order parameter –” and/or “– Choose orderby parameter –” it will go with WordPress’ default(s), see here for more information.
The following filters are available:

srpw_get_args to override arguments of main query for the widget.
srpw_template to override the output template for the widget, see below for more information.
srpw_WIDGET_NAME_template to override the output template for the widget on a widget by widget basis, the WIDGET_NAME appears on the back-end in the widgets window see below for more information.
widget_title this is a WordPress core filter see here for more information.
srpw_post_types to override the post types available for this widget.
srpw_taxonomies to override the taxonomies available for this widget.

Usage of srpw_template filter
Add a “views” directory and file named “custom-srpw.php” to your template directory. The “custom-srpw.php” file will be your custom template for this example.
Example of using a custom template from within your theme pre-PHP 5.3

Example of using a custom template from within your theme PHP 5.3+ which allows anonymous functions

Grunt
This plugin takes advantage of Grunt for validating JavaScript, SASS compilation and minification. To take advantage of Grunt you have to have both npm and Grunt installed. Visit the respective sites for the applications and make sure they are installed. Once installed, if you want to edit/fork this plugin, it will be helpful to be familiar with these two tools.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon