Plugin / Advanced Custom Fields : CPT Options Pages

Tusko Trush

Description

Description

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.

License

Copyright (c) 2018, 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).

Ratings

5
6 reviews

Rating breakdown

Details Information

Version

2.0.4

First Released

04 Jul, 2016

Total Downloads

13,386

Wordpress Version

3.0 or higher

Tested up to:

5.2.4

Require PHP Version:

-

Tags

Contributors

Languages

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.