Last active
February 5, 2020 16:11
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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