[WordPress] 外掛分享: ACF: Fields in Custom Table

首頁外掛目錄 › ACF: Fields in Custom Table
WordPress 外掛 ACF: Fields in Custom Table 的封面圖片
90+
安裝啟用
★★★★★
5/5 分(2 則評價)
1758 天前
最後更新
問題解決
WordPress 4.9.0+ PHP 7.0+ v0.5 上架:2020-11-25

內容簡介

這款 ACF 外掛可以讓你將 ACF 數據存儲在結構化數據庫表中,而不是 WordPress 核心 meta 表中。

它使用 ACF 的 acf/update_field_group 鉤子來創建/更新數據庫,然後使用 acf/save_post 鉤子來存儲數據。

它深受 Austin Ginder 的文章「https://anchor.host/acf-custom-fields-stored-in-custom-table/」的啟發。

你可以通過在 https://github.com/eduardo-marcolino/acf-fields-in-custom-table 上提交 PR/Issue 來貢獻這款外掛。

支持的字段

文本
文本區域
數字
範圍
電子郵件
網址
密碼
圖片
文件
所見即所得編輯器
oEmbed
下拉框
勾選框
單選按鈕
按鈕組
真假值
日期選擇器
日期時間選擇器
時間選擇器
顏色選擇器
鏈接
文章對象
頁面鏈接
關聯
分類法
用戶

關聯字段

此外掛支持以下關聯字段類型:文章對象、頁面鏈接、關聯、分類法和用戶。

它可以根據 multiple 選項存儲單個和多個值。

如果它是單個值字段,則列類型為 bigint(20) unsigned
如果它是多個值字段,則列類型為 longtext,並使用 json 格式存儲日期。

你可以使用 MySQL 的函數 JSON_CONTAINS 查詢具有多個值的關聯字段。
以下是一個示例:

數據表:

+---------+-------------------+--------+
| post_id | title | stores |
+---------+-------------------+--------+
| 1 | 蒼蠅王 | [1,2] |
| 2 | 孤島驚魂 | [2] |
| 3 | 1984 | [3] |
+---------+-------------------+--------+

查詢:

SELECT * FROM wp_acf_books WHERE JSON_CONTAINS(stores, 2, '$')

上述查詢將返回「蒼蠅王」和「孤島驚魂」。

ACF 兼容性

此外掛已在 ACF 5 免費版本上進行了測試。

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「ACF: Fields in Custom Table」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This ACF plugin makes it possible to store ACF data in structured database tables instead of WordPress core meta tables.
It uses ACF’s acf/update_field_group hook to create/update the database and then uses acf/save_post hook to store the data.
It was heavily inspired by Austin Ginder’s post https://anchor.host/acf-custom-fields-stored-in-custom-table/.
You can contribute to this plugin by submit PR/Issue in https://github.com/eduardo-marcolino/acf-fields-in-custom-table.
Supported Fields

Text
Text Area
Number
Range
Email
URL
Password
Image
File
Wysiwyg Editor
oEmbed
Select
Checkbox
Radio Button
Button Group
True / False
Date Picker
Date Time Picker
Time Picker
Color Picker
Link
Post Object
Page Link
Relationship
Taxonomy
User

Relational Fields
This plugin supports the following relational field types: Post Object, Page Link, Relationship, Taxonomy and User.
It can store both single and multiple values based on the multiple option.

If it’s a single value field, then the column type will be bigint(20) unsigned
If it’s a multiple value field, then the column type will be longtext and the date will be stored in json format.

You can query relational fields with multiple values using using MySQL’s function JSON_CONTAINS.
Here is an example:
Table:
+---------+-------------------+--------+
| post_id | title | stores |
+---------+-------------------+--------+
| 1 | Lord of the Flies | [1,2] |
| 2 | The Island | [2] |
| 3 | 1984 | [3] |
+---------+-------------------+--------+

Query:
SELECT * FROM wp_acf_books WHERE JSON_CONTAINS(stores, 2, '$')

The query above will return “Lord of the Flies” and “The Island”.
ACF Compatibility
This plugin was tested with ACF 5 FREE Version .

延伸相關外掛

文章
Filter
Apply Filters
Mastodon