Hello, I use multiple ACF options pages on most of my sites. I usually create a unique options page for each custom post type that the site uses. ACF provides a great way to do this by specifying a post id value for each unique options page like so (look at the post_id
option):
<?php
$cpts = array(
'work' => 'Work',
'people' => 'People',
'location' => 'Location',
'brandblocks' => 'Brand Block',
'video' => 'Video',
'open-position' => 'Open Position',
);
foreach ( $cpts as $cpt_slug => $label )
{
$acf_retrieval_id = 'cpt_' . $cpt_slug;
// post type settings/options page
$cpt_acf_page = array(
'page_title' => $label . ' Settings',
'menu_title' => $label . ' Settings',
'parent_slug' => 'edit.php?post_type=' . $cpt_slug,
'menu_slug' => $cpt_slug . '-archive',
'capability' => 'edit_posts',
'post_id' => $acf_retrieval_id,
'position' => false,
'icon_url' => false,
'redirect' => false
);
// Now add the cpt option page
acf_add_options_page( $cpt_acf_page );
}
This is a great way to provide configuration options and store values for custom post type archive pages, without cluttering a global ACF options page. It provides a much nicer user experience for the site owner, where they can manage post type specific settings and values on a post type specific options page, and they can manage global site options on the main options page.
When I need to retrieve a value from a certain CPT options page, I just use the unique id. Something like: get_field('cpt_location', 'locations_intro_text')
. Unfortunately this does not work in Cornerstone which is a huge bummer. I’m hoping you can add this functionality. Currently you can retrieve fields from the main options page (i.e. {{dc:acf:option_field field="locations_intro_text"}}
), and you can retrieve values from a specific post ID, but I guess the post ID field only accepts integers, is that correct? When I try the following, I get nothing: {{dc:acf:post_field post="cpt_location" field="locations_intro_text"}}
This seems like it could be a very simple fix by simply allowing a string to be entered as the post ID.
Please let me know if this can be added soon. Thanks!