Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Snippet #004 Custom option pages with acf. https://since1979.dev/snippet-002-adding-option-pages-with-acf/
<?php
/**
* add_acf_menu_pages.
*
* Add custom option pages to the WordPRess admin with Acf
*
* @see https://since1979.dev/snippet-002-adding-option-pages-with-acf/
*
* @uses acf https://www.advancedcustomfields.com/
* @uses acf_add_options_page https://www.advancedcustomfields.com/resources/acf_add_options_page/
* @uses acf_add_options_sub_page https://www.advancedcustomfields.com/resources/acf_add_options_sub_page/
*/
function add_acf_menu_pages()
{
acf_add_options_page(array(
'page_title' => 'Theme options',
'menu_title' => 'Theme options',
'menu_slug' => 'theme-options',
'capability' => 'manage_options',
'position' => 61.1,
'redirect' => true,
'icon_url' => 'dashicons-admin-customizer',
'update_button' => 'Save options',
'updated_message' => 'Options saved',
));
acf_add_options_sub_page(array(
'page_title' => 'Theme logos',
'menu_title' => 'Theme logos',
'parent_slug' => 'theme-options',
));
acf_add_options_sub_page(array(
'page_title' => 'Seo options',
'menu_title' => 'Seo options',
'parent_slug' => 'theme-options',
));
}
/**
* Hook: acf/init.
*
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/
* @uses acf/init https://www.advancedcustomfields.com/resources/acf-init/
*/
add_action('acf/init', 'add_acf_menu_pages');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.