A simple way to create your own theme options page. This plugin requires CMB2 to work.
Include cmb-theme-options-tabs library in functions.php
or use it as WordPress plugin.
if( defined('CMB2_LOADED') ) {
require_once('cmb2-theme-options-tabs/cmb-theme-options-tabs.php');
}
Define your theme options in functions.php
function cmb2_ld_theme_options_fields()
{
$fields = array(
array(
'name' => '404 page settings',
'id' => '_ld_main_404_box_title',
'type' => 'title'
),
array(
'name' => 'Title',
'id' => '_ld_main_404_title',
'type' => 'text'
),
array(
'name' => 'Content',
'id' => '_ld_main_404_content',
'type' => 'wysiwyg',
'options' => array(
'textarea_rows' => 5
)
)
);
return $fields;
}
add_filter('cmb2_theme_options_tab_fields', 'cmb2_ld_theme_options_fields');
You can get the options like this:
echo ld_get_theme_option('_ld_main_404_title');
If you prefer to define your own tabs just use cmb2_theme_options_tab_tabs
filter to do this.
But keep in mind that in this case you have to add additional parameter to ld_get_theme_option()
function to get your theme option.
function cmb2_theme_options_tab_tabs_callback($tabs)
{
return array(
'global' => array(
'translated_name' => 'Global',
'language_code' => 'global'
)
);
}
add_filter('cmb2_theme_options_tab_tabs', 'cmb2_theme_options_tab_tabs_callback');
echo ld_get_theme_option('_ld_main_404_title', 'global');