Skip to main content

Registering Options Pages in Code

Use code registration so global settings pages are reproducible across environments.

ACF Pro Required

acf_add_options_page() and related options APIs are ACF Pro capabilities.

Practical Use Cases

Use Case 1: Register primary options page and sub-pages

wp-content/themes/your-theme/inc/acf/options-pages.php
<?php
add_action('acf/init', function () {
if (!function_exists('acf_add_options_page')) {
return;
}

acf_add_options_page([
'page_title' => 'Site Settings',
'menu_title' => 'Site Settings',
'menu_slug' => 'site-settings',
'capability' => 'manage_options',
'redirect' => false,
]);

acf_add_options_sub_page([
'page_title' => 'Header Settings',
'menu_title' => 'Header',
'parent_slug' => 'site-settings',
]);
});
?>
CLI check options API
wp eval 'var_export(function_exists("acf_add_options_page")); echo PHP_EOL;'
Expected output
true

Use Case 2: Assert registration hook is loaded in runtime

CLI hook check
wp eval 'echo has_action("acf/init") ? "acf-init-hooked" : "missing"; echo PHP_EOL;'
Expected output
acf-init-hooked

Hands-On Practice

  1. Add options page registration file and load it in theme bootstrap.
  2. Verify acf_add_options_page availability with wp eval.
  3. Add one release smoke check for options-page hook registration.

What's Next