Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active February 5, 2020 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanaf1979/74681488ba155dd7a9313324bbece146 to your computer and use it in GitHub Desktop.
Save vanaf1979/74681488ba155dd7a9313324bbece146 to your computer and use it in GitHub Desktop.
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