Blog /

ACF: Options page within any other menu

Do you need to add custom options page with ACF under another WP menu? Use this snippet.

If you are using Advanced Custom Fields PRO, you might already be using a customs options page. Have you been thinking about how to add this kind of settings page to your Custom Post Types, or elsewhere?

It’s not complicated at all, just check out the following snippet:


<?php // ommit this line
/**
* @snippet Add ACF Pro settings page under a menu item of your choice
* @comment In case you'd like to add your option page to the CPT, under posts or whatever location you'd like
* @source https://kybernaut.cz/clanky/wp-multisite-maximalni-velikost-nahravaneho-souboru/
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @testedwith WordPress 5.0.5
*/
// ——————-
if( function_exists('acf_add_options_sub_page') ) {
// add sub page
acf_add_options_sub_page(array(
'page_title' => 'Title of your custom option page',
'menu_title' => 'Menu title',
'parent' => 'edit.php?post_type=YOUR-CPT-GOES-HERE', // works as normal parent_slug from https://developer.wordpress.org/reference/functions/add_submenu_page/
'capability' => 'manage_options'
));
}

The parent param can have the same values as parent_page from add_submenu_page.