這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

Advanced Custom Fields : CPT Options Pages

描述

Small addon for ACF Options. Adds ACF location for each custom post type.

New feature in the major version 2!
Important!
After update to v2+ you must reconnect Field Groups to Options Pages

Now you can activate/deactivate CPTs and create custom options pages for each CPT.
By default, options pages are activated for all custom post types.

Usage

The default functions of ACF plugin (get_field, the_field, etc.) can be used to load values from a CPT Options Pages, but second parameter is required to target the CPT options.

This is similar to passing through a $post_id parameter to target a specific post object.

The $post_id parameter needed is a string containing the cpt_ and CPT name in the following format; "cpt_{CPT_NAME}" and for subpages you can copy generated ID while creating subpages.

Examples

In examples Custom Post Type name is projects.

So, let’s go!

Display a field

<p><?php the_field('field_name', 'cpt_projects'); ?></p>

and the subpage’s field

<p><?php the_field('field_name', 'cpt_projects_testpage'); ?></p>

Retrieve a field

<?php
    $field = get_field('field_name', 'cpt_projects');
    // do something with $field
?>

Display a sub field

    <?php if( have_rows('repeater_name', 'cpt_projects') ): ?>
        <ul>
            <?php while( have_rows('repeater_name', 'cpt_projects') ): the_row(); ?>
                <li><?php the_sub_field('the_title'); ?></li>
            <?php endwhile; ?>
        </ul>
    <?php endif; ?>

Display with shortcode

[acf field="field_name" post_id="cpt_projects"]

Please read documentation about shortcodes with ACF

Customization

    function cpt_projects_customize($cptmenu) {
        $cptmenu['page_title'] = 'Dev Custom title';
        $cptmenu['menu_title'] = 'Dev Custom title';
        return $cptmenu;
    }

    add_filter('cpt_projects_acf_page_args', 'cpt_projects_customize');

Don’t forget to replace cpt_projects_ to your custom post type name 🙂
It works only for first level options pages, not for subpages.

Donate

Support plugin

License

Copyright (c) 2021, Tusko Trush

Requirements

You must buy ACF PRO or ACF Options Page Addon.

Translation

qTranslate-XT

This plugin is compatible and has included ACF qTranslate.
Just enjoy!

qTranslate-X

If you are using Qtranslate-X, you must install ACF qTranslate.

WPML/Polylang

If you are using WPML or Polylang, you must add constant ICL_LANGUAGE_CODE to post_id,
for example: get_field('archive_title', 'cpt_projects_' . ICL_LANGUAGE_CODE).

螢幕截圖

  • assets/screenshot-1.png

安裝

  1. Upload ‘acf-cpt-options-pages’ to the /wp-content/plugins/ directory.
  2. Activate the plugin through thePlugins menu in WordPress.
  3. Go to Custom fields submenu CPT Options page and activate CPTs what you need or create subpages for that.
  4. Create your Custom Field Group, set location rule Options Page and choose your CPT options page or subpage.
  5. Read the documentation to display your data.

常見問題

If you have any questions on this please post an issue/question at Github Issues

評價

2020年2月18日
The great plugin which I have been looking for a long time!! The great plugin which I have been looking for a long time!! It works easy and awesome!
2017年7月1日
I did not know that such a basic plugin can be there that lets me create the options page with such ease.
2016年11月16日 1 reply
Smart, intuitive and works exactly as advertised. Just what I needed for archive pages custom headings but I'm certain I will find other ways of using this excellent tool.
閱讀全部7個評價

貢獻者及開發者

“Advanced Custom Fields : CPT Options Pages” 是一個開源的軟體。以下的人對這個外掛作出了貢獻。

貢獻者

Advanced Custom Fields : CPT Options Pages 外掛目前已有 3 個本地化語言版本。 感謝所有譯者為這個外掛做出的貢獻。

將 Advanced Custom Fields : CPT Options Pages 外掛本地化為台灣繁體中文版。

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

修改日誌

2.0.8

  • Tested up with WP 5.8.1 and ACF Pro 5.10.2
  • Fix lang switcher and Wysiwyg Editor capability on ACF CPT Options pages
  • Modified page slug ‘-options’ -> ‘acfcpt-options’ to make qTranslate config regex

2.0.7

  • Tested up 5.7.2
  • @Ekeler PR: Update class.acf-cpt-options-pages.php

2.0.6

  • Tested up 5.7.1
  • Added apply_filters cpt_options_post_types_params

2.0.5

  • Tested up 5.3.2
  • Fix donate links

2.0.4

  • Tested up 5.2.1
  • Assets updated

2.0.3

  • Fixed underscores in options pages title

2.0.2

  • Fixed WPML slugs

2.0.0

  • Added Russian, Ukrainian translations.
  • Added setting page to ACF CPT Options Pages
  • Added UI to manage options pages per CPT
  • Ability to add child pages to CPTs

1.1.0

  • Support MO translations
  • Customization using add_filter

1.1.0

  • WPML and Polylang compatibility added.

1.0.2

  • Update documentation.
  • Change labels and slugs.

1.0.1

  • Plugin created.