[WordPress] 外掛分享: Advanced Custom Fields: Archive Templates

首頁外掛目錄 › Advanced Custom Fields: Archive Templates
900+
安裝啟用
★★★★★
5/5 分(2 則評價)
2124 天前
最後更新
問題解決
WordPress 4.1+ PHP 5.4+ v1.0.6 上架:2018-10-24

內容簡介

ACF Archives 是一個小型的外掛程式,可幫助您將 ACF 字段添加到檔案存檔範本中。
此外掛將為每個定義了檔案存檔的公開自訂文章類型添加一個子選單
然後您可以在 ACF 規則框中選擇。

想要為其他自訂文章類型添加或移除子選單嗎?

這是您可以在佈景主題的functions.php中添加的代碼範例

add_filter( 'acf_archive_post_types', 'change_acf_archive_cpt' );
function change_acf_archive_cpt( $cpts ) {
// 'book' 和 'movie' 是自訂文章類型的鍵。

// 移除自訂文章類型
unset( $cpts['book'] );

// 添加自訂文章類型
$cpts['movie'] = Movies Archive;

return $cpts;
}

在檔案存檔頁面中取得 ACF 欄位
$object = get_queried_object();
$field = get_field( 'field_name', $object->name );

var_dump( $field );

從 WordPress 內部

造訪「外掛 > 新增」的選單
尋找「acf archive」
從外掛頁面啟用 ACF Archive

手動安裝

將acf-archive資料夾上傳到/wp-content/plugins/目錄中
透過 WordPress 的「外掛」選單啟用 ACF Archive

外掛標籤

開發者團隊

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

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

原文外掛簡介

ACF Archives is a little plugin for helping you attach ACF fields to the archive template.
The plugin will add a submenu for each public custom post type with archive defined
and then you can select under ACF rules box.
Want to add or remove the submenu for other custom post types?
Here is a code example you can add to to your theme functions.php
add_filter( 'acf_archive_post_types', 'change_acf_archive_cpt' );
function change_acf_archive_cpt( $cpts ) {
// 'book' and 'movie' are the cpt key.

// Remove cpt
unset( $cpts['book'] );

// Add cpt
$cpts['movie'] = Movies Archive;

return $cpts;
}

Get the acf field on archive page
$object = get_queried_object();
$field = get_field( 'field_name', $object->name );

var_dump( $field );

From within WordPress

Visit ‘Plugins > Add New’
Search for ‘acf archive’
Activate ACF Archive from your Plugins page.

Manually

Upload the acf-archive folder to the /wp-content/plugins/ directory
Activate the ACF Archive plugin through the ‘Plugins’ menu in WordPress

延伸相關外掛

文章
Filter
Mastodon