[WordPress] 外掛分享: ACF Media Cluster

首頁外掛目錄 › ACF Media Cluster
10+
安裝啟用
尚無評分
1228 天前
最後更新
問題解決
WordPress 3.6.0+ v1.0.0 上架:2021-07-27

內容簡介

ACF 媒體叢集是進階自訂欄位的一個擴充外掛程式,它添加了將多媒體添加到文章/頁面的功能。插件提供了短代碼,或者如果您知道如何編寫代碼,則可以自定義或編寫自己的代碼並根據 ACF 媒體叢集提供的數據使用。

視覺化創建您的自訂欄位
添加多媒體,您還可以將標題、說明和描述修改為任何內容
通過編寫自定義位置規則將您的欄位分配給多個編輯頁面
通過一個簡單友好的 API 輕鬆加載數據
使用本地 WordPress 自訂文章類型,易於使用和快速處理
使用本地 WordPress 元數據,易於使用和快速處理

用法

使用下面的輔助函式從資料庫中提取資料。該輔助函式將返回一個數組。輔助函式接受三個參數。

acf_media_cluster(string|required $acf_field_name, int $postID, array $options);

範例

基於上述的輔助函式。假設我們想要從當前頁面中提取年度報告。

acf_media_cluster('annual_reports', get_the_ID());

將返回的數據為一個數組。現在可以遍歷數組並按照您的方式使用數據。

$ap = acf_media_cluster('annual_reports', get_the_ID());
if( !empty($ap) ){
foreach($ap as $item){
var_dump($item); //按照您的方式使用數據
}
}

選項

acf_media_cluster(string|required $acf_field_name, int $postID, array $options); 輔助函式的第三個參數是指選項,它接受一個陣列。您可以傳遞以下選項。

acf_media_cluster('annual_reports', array(
'orderby' => 'post__in',
'order' => 'ASC'
));

您可以傳遞哪些值用於排序和按什麼排序,請參閱 https://developer.wordpress.org/reference/functions/get_posts/

短代碼

在您的編輯器的文本檢視中,在您希望媒體出現的位置添加以下短代碼。

[acf-media-cluster field_name="discussions" container_id="ml-table" container_class="ml-table2" skin="yes"]

短代碼接受以下參數。

string|required $field_name – 使用哪個 ACF 欄位名稱
string $container_id – 用您的自定義 CSS ID 包裝輸出
string $container_class – 用您的自定義 CSS 類別包裝輸出
string $skin – 您是否希望應用默認的 CSS 樣式。 yes|no

問題

就像任何其他 WordPress 外掛程式一樣,這個外掛程式也可能導致其他主題和外掛程式的問題。如果您在使用此外掛程式時遇到問題,在支援論壇中請求幫助。這樣我們就可以幫助您解決問題,並防止這個問題發生在其他人身上。如果您想直接與我交談,可以通過我的網站 http://www.navz.me/ 聯繫我。

兼容性

此 ACF 自訂欄位類型與:
* ACF 5

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「ACF Media Cluster」→ 直接安裝(推薦)

原文外掛簡介

ACF Media Cluster is an extension for Advance Custom Fields which adds the feature to add multiple media to post/pages. The plugin does come with shortcode or if you know how to write code then you can customize or write your own code and use the data provided by ACF Media Cluster as you wish.

Visually create your Fields
Add multiple media and you can also modify title, caption and description to anything
Assign your fields to multiple edit pages (via custom location rules)
Easily load data through a simple and friendly API
Uses the native WordPress custom post type for ease of use and fast processing
Uses the native WordPress metadata for ease of use and fast processing

Usage
Use the helper function below to pull data from the database. The function will be return an array. The helper function takes in 3 parameters.
acf_media_cluster(string|required $acf_field_name, int $postID, array $options);

Example
Based on the helper function above. Let say we want to pull annual reports from current page.
acf_media_cluster('annual_reports', get_the_ID());

The data that will be return will be an array. Now I can loop over the array and use the data anyway I want.
$ap = acf_media_cluster('annual_reports', get_the_ID());
if( !empty($ap) ){
foreach($ap as $item){
var_dump($item); //Use the data as you wish
}
}

Options
The 3rd parameter of the acf_media_cluster(string|required $acf_field_name, int $postID, array $options); helper function is options which takes in an array. You can pass the following.
acf_media_cluster('annual_reports', array(
'orderby' => 'post__in',
'order' => 'ASC'
));

What are the values you can pass for order and orderby, please refer to https://developer.wordpress.org/reference/functions/get_posts/
Shortcode
In the text view of your editor, add the following shortcode where you want the media to appear.
[acf-media-cluster field_name="discussions" container_id="ml-table" container_class="ml-table2" skin="yes"]

The shortcode takes in the following parameters.
string|required $field_name – Which ACF field name should be used
string $container_id – Wrap the output with your custom CSS ID
string $container_class – Wrap the output with your custom CSS class
string $skin – Do you want default CSS styling to apply. yes|no
Issues
Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website http://www.navz.me/
Compatibility
This ACF field type is compatible with:
* ACF 5

延伸相關外掛

文章
Filter
Apply Filters
Mastodon