이 플러그인은 최근 3개의 주요 워드프레스 출시와 시험 되지 않았습니다. 워드프레스의 좀 더 최근 버전으로 이용할 때 더 이상 관리되지 않고 지원되지 않고 호환성 문제가 있을 수 있습니다.

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

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

Manually

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

스크린샷

  • New Archive ACF rule under ACF rules
  • ACF Archive menu page under each custom post type with archive enabled.

후기

2020년 3월 28일
Thank you for your contribution, but in order to expand the correct menu item, I had to make some edits to your plugin: /** * Load the ACF Assets only on archive options page * @param string $hook_suffix * @return void */ public function admin_enqueue_scripts( $hook_suffix ) { $screen = get_current_screen(); if ( strpos($_GET['page'], 'archive-options') !== FALSE ) { acf_enqueue_scripts(); } } /** * Add ACF menu page for each custom post type * * @param string $label * @param string $menu */ private function add_menu( $label, $menu, $post_type ) { $page_name = sprintf( __( '%s Archive', 'acf-archive' ), $label); $options = [ 'parent_slug' => $menu, 'page_title' => $page_name, 'menu_title' => $page_name, 'capability' => 'edit_posts', 'menu_slug' => 'archive-options-'.$post_type, ]; add_submenu_page( $options['parent_slug'], $options['page_title'], $options['menu_title'], $options['capability'], $options['menu_slug'], [ $this, 'render_menu' ] ); } /** * Check if we are in the current post type for showing the fields. * * @param $match * @param $rule * @param $options * @return bool */ public function location_rules_match_archive( $match, $rule, $options ) { if ( ! isset( $_GET['post_type'] ) || ! isset( $_GET['page'] ) ) { return $match; } return $_GET['post_type'] == $rule['value'] && strpos($_GET['page'], 'archive-options') !== FALSE; }
모든 1 평가 읽기

기여자 & 개발자

“Advanced Custom Fields: Archive Templates”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

자국어로 “Advanced Custom Fields: Archive Templates”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

1.0.6

Just update some info

1.0.4

Fixed: Rule match bug

1.0.3

Compatibility when ACF is loaded on the theme

1.0.2

Code refactor and better compatibility

1.1

Minor fix for CPT UI

1.0

Initial Release