
內容簡介
- ACF My Media Cluster是Advance Custom Fields的擴展,可以在頁面/文章/自定義文章類型上創建媒體文件的下載群組。
- 該插件提供了簡單易用的短碼和輔助函數,如果您希望自定義輸出,可以使用它們。
- 可以在ACF界面中直觀地創建自己的字段。
- 將字段分配給文章類型。
- 通過簡單友好的輔助函數輕鬆加載數據,或者只需使用短碼即可。
- 使用原生WordPress自定義文章類型來提供使用方便和快速處理。
- 使用原生WordPress元數據提供使用方便和快速處理。
- 可以向文章、頁面和自定義文章類型添加多個媒體文件,還可以從這個界面修改標題、說明和描述。
使用方法:
- 使用下面的輔助函數從數據庫中取出數據。該函數將返回一個數組。輔助函數需要三個參數。
- 例如:假設我們想從當前頁面中提取年度報告。
- 返回的數據將是一個數組,您可以遍歷該數組並根據需要使用數據。
- 第三個參數是輔助函數的選項,它接受一個數組。您可以傳遞以下參數。
-在編輯器中,將以下短碼添加到您希望媒體出現的位置。
-該短碼接受以下參數。
相容性:
- ACF My Media Cluster與ACF 6和ACF 5兼容。
- 這個ACF字段與iThemes Security插件兼容,但在系統調整的「PHP執行」下的「禁用插件中的PHP」選項必須取消勾選。
插件來源:
- 這個插件是基於Navneil Naicker的ACF Media Cluster插件開發的。
- 它也從dfactory的Download Attachments插件中獲得了一些靈感,不過該插件已經不存在了。
問題和答案:
問題1:ACF My Media Cluster 是做什麼用的?
答案1:ACF My Media Cluster是Advance Custom Fields的擴展,可以在頁面/文章/自定義文章類型上創建媒體文件的下載群組。
問題2:ACF My Media Cluster提供了哪些使用方式?
答案2:ACF My Media Cluster提供了簡單易用的短碼和輔助函數可以自定義輸出,也可以在ACF界面中直觀地創建字段。
問題3:如何從數據庫中提取數據?
答案3:可以使用下面的輔助函數從數據庫中提取數據,該函數返回一個數組。
問題4:ACF My Media Cluster與哪些版本相容?
答案4:ACF My Media Cluster與ACF 6和ACF 5相容。
問題5:ACF My Media Cluster和哪個插件有相似之處?
答案5:ACF My Media Cluster受到了Navneil Naicker的ACF Media Cluster插件和dfactory的Download Attachments插件的啟發。
外掛標籤
開發者團隊
原文外掛簡介
ACF My Media Cluster is an extension for Advance Custom Fields which adds the feature to create groups of media files for download on a page/post/custom post type. The plugin does come with both a simple to use shortcode and a helper function if you wish to customize your output.
* Visually create your Fields in the ACF interface.
* Assign your fields to post types
* Easily load data through a simple and friendly helper function, or just use the shortcode.
* 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
* Add multiple media files to your posts, pages, and custom post types. You can also modify title, caption and description from this interface.
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. You can then loop over the array and use the data anyway you 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', get_the_ID(), array(
'orderby' => 'post__in',
'order' => 'ASC'
));
For acceptable values for order and orderby, please refer to https://developer.wordpress.org/reference/functions/get_posts/
Shortcode
In your editor, add the following shortcode where you want the media to appear.
[acf-media-cluster field_name="my_media_field"]
The shortcode accepts 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 name
string $container_class – Wrap the output with your custom CSS class name
string $skin – Do you want default CSS styling to apply? yes|no
string $format – html format for the output. table|list
string $title – a title wrapped in an container tag. Leave blank for no tag.
string $title_container – html tag to wrap the title in, with no brackets. “h3” is default.
string $show_meta – Do you want to display file metadata (size, downloads, date)? yes|no
Compatibility
This ACF field type is compatible with:
* ACF 6
* ACF 5
This ACF field is compatible with the iThemes Security plugin, but you must uncheck the option for “Disable PHP in plugins” under PHP Execution in System Tweaks.
Credits
This plugin is based on ACF Media Cluster by Navneil Naicker. (https://wordpress.org/plugins/acf-media-cluster/)
It also takes some inspiration from the Download Attachments plugin by dfactory, which sadly no longer exists.
