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

WordPress 外掛 ACF Recent Posts Widget 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「ACF Recent Posts Widget」是 2015-03-13 上架。
  • 目前有 700 個安裝啟用數。
  • 上一次更新是 2023-11-20,距離現在已有 530 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.6 以上版本才可以安裝。
  • 有 12 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

gicolek | patopaiar |

外掛標籤

acf | posts | recent | widget | meta keys |

內容簡介

ACFRPW 外掛新增了一個部件至「外觀」→「小工具」→「ACF 最新文章部件」。大部分欄位都相當明顯,您可以從一個設定集中選擇想要顯示的文章。
每個設定會改變側邊欄列出的文章數量和類型。

可用設定

部件支援以下設定:

部件標題
自訂部件容器 CSS 類別
忽略置頂文章選擇
搜尋關鍵字查詢
基於 ID 的文章排除
日期顯示、日期修改、相對和自訂日期格式規格
列出特定日期區間(開始和結束)的文章
列出特定密碼的文章,僅列出密碼保護的文章或排除這些文章
文章類型選擇
文章格式選擇
文章狀態選擇
限制特定作者的文章,透過作者 ID
排序規格(升序或降序)
排序子規格(ID,作者,標題,日期,修改日期,隨機,評論數,選單順序,Meta Value,Meta Value Numeric)
Meta Key 規格(如果以 Meta Value 或 Meta Value Numeric 為排序規則時)
Meta Comparison 選擇
Meta Value 規格(針對 Meta Comparison 選擇)
限制分類
限制標籤
基於 ID 的自訂分類限制
這些規則的運算子規格
要顯示的文章數量
要跳過的文章數量
縮略圖顯示,縮略圖大小(寬度、高度)、縮略圖對齊、預設縮略圖
節錄顯示,詞語限制,顯示其「閱讀全文」文字(僅發生詞語數超過節錄限制時)
要顯示於迴圈前的自訂 HTML
要顯示於迴圈後的自訂 HTML
要顯示於每篇文章之前的自訂 HTML,支援自訂 Meta Key 和 ACF 欄位
要顯示於每篇文章之後的自訂 HTML,支援自訂 Meta Key 和 ACF 欄位
沒有文章時要顯示的自訂 HTML
自訂和預設的 CSS
自訂 HTML 樣板

ACF 支援的欄位

此外插件已經使用 ACF 4(免費版)進行編寫和測試。自從版本 4.1.5,ACF Pro 也得到了支援,但是代碼沒有保證 - 這是測試版,並且只在 ACF Pro 和 ACF Free 沒有更大差異時才會保留。

此插件支援以下 ACF 欄位:

文字
文字區
數字
電郵
密碼
所見即所得編輯器
圖片
檔案

目前未測試其他欄位,因此不予支援。

簡碼

自從版本4.4起,該插件支援簡碼嵌入。考慮到選項的數量以及它們的特定名稱(如簡碼屬性),新增了簡碼建立者(請參閱第7和第8個截圖)。

單擊ACFRPW按鈕後,您會看到一個彈出窗口,讓您自動為您設置簡碼代碼。 其餘部分遵循此處指定的所有選項。

要使用簡碼,您需要啟用 WordPress 編輯器以供當前頁面/文章類型使用。如果禁用了它(例如通過ACF),則該按鈕將不會出現。

創建自訂模板

自從版本4.3開始,該插件支援自訂模板。 為了使用這些功能,您需要複製acfrecent-postswidget/templates目錄中找到的所有文件,並將其複製到活動臨時文件夾中。

原文外掛簡介

ACFRPW adds a new widget to the Appearance -> Widgets -> ACF Recent Posts Widget. Most of the fields are quite obvious, you can choose from a set of settings to display the posts from.
Each setting alters the amount and type of posts listed in the sidebar.

Available Settings
The widget supports the following settings:

Widget Title
Custom Widget container CSS class
Option to ignore sticky posts
Search keyword query
Id based post exclusion
Date Display, Date Modified, Relative and Custom Date Format specifiaction
Listing posts from specific date period (start and end)
Listing posts with specific password, listing password protected posts only or excluding these
Post Type selection
Post Formats selection
Post Statuses selection
Listing posts limited to author via author id
Order specifiaction (ASC or DESC)
Orderby specification (ID, Author, Title, Date, Modified, Random, Comment Count, Menu Order, Meta Value, Meta Value Numeric)
Meta Key specifiaction (if Meta Value or Meta Value Numeric were chosen as orderby rule)
Meta Comparison selection
Meta Value Specification (for the Meta Comparison selection)
Category limitation
Tag limitation
Id based custom taxonomy limitation
Operator specifiaction for the above rules
Number of posts to show
Number of posts to skip
Thumbnail display, thumbnail size (width, height), thumbnail alignment, default thumbnail
Excerpt display, its word limit, its readmore text (occurs only if the amount of words exceeds the limit)
Custom HTML to display before the loop
Custom HTML to display after the loop
Custom HTML to display before each posts. It supports custom meta keys and ACF fields
Custom HTML to display after each posts. It supports custom meta keys and ACF fields
Custom HTML to display for no posts found
Custom and default CSS
Custom HTML templates

ACF supported fields
The plugin has been tested with ACF 6 (Free and Pro).
The plugin supports the following ACF fields:

Text
Textarea
Number
Email
Password
Wysiwg Editor
Image
File

No other fields have been tested and are supported at the moment.
Shortcode
From version 4.4 the plugin supports shortcode embeds. Given the amount of options and their specific names (as in shortcode attributes) the shorcode builder has been introduced
see 7th and 8th screenshots for the reference.
You’ll see a popup once clicked on ACFRPW button which gives one an ability to automatically set up the shortcode code for you. The rest follows all of the options specified here.
To use the shortcode one needs to have the WordPress editor enabled for the current page / post type. In case it was disabled (say via ACF) the button won’t appear.
Creating Custom Templates
From version 4.3 the plugin supports custom templates. To make usage of these one needs to make a copy of all the files found
in the acf-recent-posts-widget/templates directory and copy them over to the active template directory to acfrpw subdirectory.
The approach is similar to the way WooCommerce plugin works and has it’s drawbacks. With every new feature the files may be outdated.
Similarly to the widget template files, a separate, custom markup can be created for the shortcode build post listing. Copy the acf-recent-posts-widget/template files
to acfrpw-blog directory created inside your active theme directory.
Template files
There are 3 main template files:

loop-after.php (which displays the markup after each of the posts and closes the markup container)
loop-before.php (which displays the markup before each of the posts and opens the markup container)
loop-inner.php (which is enqueued for each of the posts separatelly and contains the markup of every single post)

Usage
The usage is quite advanced hence each template file contains a quite detailed documentation on how to use it.
First of all the template files mustn’t have the global variables removed. Each of these variables stores the widget settings, which are then used to generate the code.
Second of all the variable names are unobvious, loop-inner.php template file contains a list of all the names used, which are then extracted and available as php variables.
Different template per widget / sidebar
The templates allow one to adjust the markup of each single widget. One needs first to verify the widget id used, which may then be referenced.
The variable which stores the widget id is $acf_rpw_args[‘widget_id’]. Dumping the value in the template is the best way to find out which automatic id has been created for your widget.
The best way to handle the templates is to learn from their code. My personal suggestion is to copy over the templates to the current theme and work directly on them, doing one change at a time.
The templates require learning curve to use and there’s no single answer to everyones problem.
Complex usage
This section covers plugin complex usage for advanced user willing to have more control over the behavior of the plugin as well as explains uncommon functionalities.
Using the HTML textarea fields
These sections might not be obvious. The HTML or text before / after the whole loop setting is an area where you can specify custom HTML markup to be added before / after the whole posts list.
The HTML or text before / after each post is an area where you can not only specify custom HTML, but you are also given an ability to print any meta key or certain ACF fields (see ACF supported fields)
Meta Key Name / ACF Usage
These fields need to be wrapped inside the {meta name} or {acf field_name} tags (which are similar to shortcodes). The plugin will then parse these fields and print their according value. Say we have a custom ACF field of type text, for which the Field Name is “text”.
To print its value one has to use [acf text] inside the befoe / after each post textarea. A similar solution applies to the meta key.
Meta Value Usage
The Meta Value field supports an array of elements, so that all of the meta_compare parameters could be used. To do so, please specify the two parameters separated by semicolon, for instance: 1234;12345.
The plugin will convert these into an array and apply the proper operation for the two. Whatsmore the [date] shortcode can be used here. It takes the timestamp paramater as an argument, which is required – the possible arguments are the same as for
the function described here: http://php.net/manual/pl/function.strtotime.php. For instance [date +1 day] would generate the tomorrow date in “Ymd” format.
This can be used with custom meta field date.
Plugin Filters
The are several filters that can be used to enchance the plugin programatically:

‘acf_rwp_query’ which gives one the ability to filter the query applied to each widget.
‘acp_rwp_before’ which gives on the ability to filter the Front End output of the plugin before each post. There are two hooks attached here already which allow usage of the [acf] and [meta] shortcodes.
‘acp_rwp_after’ which gives on the ability to filter the Front End output of the plugin after each post. There are two hooks attached here already which allow usage of the [acf] and [meta] shortcodes.
‘acf_meta_value’ which filters the meta_value query parameter.

Check the acf_widget_widget file for the arguments and use cases.
Dependencies

ACF (optional)
Widget Base Class (included)
Shortcode popups generator (included)

Other

Online Demo
Plugin site and Docs
Plugin Development Survey

Languages Supported

English (default)
Polish (since May 11 2015)
French (since June 29 2015), by wolforg, standalone source
Spanish (since July 30 2023)

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「ACF Recent Posts Widget」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


4.2 | 4.3 | 4.4 | 4.5 | 4.6 | 5.3 | 5.9 | 4.1.2 | 4.1.3 | 4.1.4 | 4.1.5 | 4.1.6 | 4.2.1 | 4.6.1 | 4.6.2 | 5.2.3 | 5.2.4 | 5.9.2 | 5.9.3 | 5.9.4 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon