I would like to have an options page that is located inside the menu for a custom post type. Then all the fields for that options page can then be used as a static part of the CPT’s post page template.
The menu would look like this:
OFFERS
— All Offers
— New Offer
— Categories
— Offers Page Content
Does that make sense?
Thanks in advance!
Hi @robertrhu
You should be able to do it like this:
if( function_exists('acf_add_options_page') ) {
acf_add_options_sub_page(array(
'page_title' => 'Offers Page Content',
'menu_title' => 'offers-page-content',
'parent_slug' => 'edit.php?post_type=offers',
));
}
Where ‘offers’ is the slug of your custom post type.
I hope this helps 🙂
Thanks! Then I can just call the custom fields in the page template that the post type uses?
Hi @robertrhu
I’m not sure I understand your query. Could you please explain it in more detail? If you can, could you please share some screenshots with notes on how you want to accomplish it?
If you want to get the custom fields value on the options page, you need to pass option
to the second parameter of the get_field() or the the_field() function. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/.
Thanks 🙂
That did the trick! Thanks a ton for all your help James!
You can use a plugin ACF CPT Options Pages