Creating a custom options page in WordPress backend with Advanced Custom Fields
You could want to have an options page where you can set something for a global usage on your website. Before start be sure to install the latest version of Advanced Custom Fields PRO (paid plugin).
Create the options page
Add this code to your functions.php
/**
* Options page
*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'General settings for your theme',
'menu_title' => 'Theme settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
Add the custom fields to the options page
From the WP backend go to Custom Fields section, create a new group, add the fields and assign the group to Theme settings
(that is the name specified in the code above) using the the rule:
if Options Page = Theme settings
Accessing to the custom fields from the front-end
$custom_field = get_field('custom_field_name', 'option');