[wordpress插件] Advanced Custom Fields: Archive Templates高级自定义字段:存档模板

wordpress 插件 文章 2020-01-26 04:20 621 0 全屏看文

AI助手支持GPT4.0

评分

100

100

描述

ACF Archives is a little plugin for helping you attach ACF fields to the archive template.

ACF Archives是一个小插件,可帮助您将ACF字段附加到存档模板。

The plugin will add a submenu for each public custom post type with archive defined

该插件将为每种公共自定义帖子类型添加一个子菜单,其中定义了存档

and then you can select under ACF rules box.

然后您可以在“ ACF规则”框中选择。

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

这是一个代码示例,您可以将其添加到主题函数中。php

    add_filter( 'acf_archive_post_types', 'change_acf_archive_cpt' );    

  add_filter('acf_archive_post_types','change_acf_archive_cpt');    

function change_acf_archive_cpt( $cpts ) {        

函数change_acf_archive_cpt($ cpts){        

// 'book' and 'movie' are the cpt key.        

//'book'和'movie'是cpt键。        

// Remove cpt        

//删除cpt        

unset( $cpts['book'] );        

unset($ cpts ['book']);        

// Add cpt        

//添加cpt        

$cpts['movie'] = Movies Archive;        

$ cpts ['movie'] =电影档案;        

return $cpts;    

返回$ cpts;    

}

}

Get the acf field on archive page

在存档页面上获取acf字段

    $object = get_queried_object();    

  $ object = get_queried_object();    

$field = get_field( 'field_name', $object->name );    

$ field = get_field('field_name',$ object-> name);    

var_dump( $field );

var_dump($ field);

From within WordPress

在WordPress内部

    1. Visit ‘Plugins > Add New’
    2. 访问“插件>添加新内容”

    3. Search for ‘acf archive’
    4. 搜索“ acf存档”

    5. Activate ACF Archive from your Plugins page.
    6. 从“插件”页面激活ACF存档。

    Manually

    手动

      1. Upload the acf-archive folder to the /wp-content/plugins/ directory
      2. acf-archive 文件夹上传到 / wp-content / plugins / 目录

      3. Activate the ACF Archive plugin through the ‘Plugins’ menu in WordPress
      4. 通过WordPress中的“插件”菜单激活ACF存档插件

下载地址

https://downloads.wordpress.org/plugin/acf-archive.1.0.5.zip

https://downloads.wordpress.org/plugin/acf-archive.1.0.5.zip

-EOF-

AI助手支持GPT4.0