Creating a parent WordPress menu theme option


We can create a theme option easily using option tree plugin. You can use this plugin as plugin mode and also you can use this plugin inside your theme folder. To use it as plugin is very simple. Just install the plugin and you will have the option to use it in the WordPress dashboard menu. Check the below image if you install the plugin and use it as a plugin.

Now I am going to show you two way in the theme mode. You can use the option tree plugin in the them mode also. to do so download the plugin first from WordPress.org and then copy the full folder into your theme folder. After that just add the below code to your theme function to load the option tree into your theme.

After that you just add theme option and integrate it to your theme code.

Now the way I am going to tell you is what I was looking for many days. I wanted the theme option menu as a parent menu in WordPress dashboard and not under Appearance menu. You can do that by following the below steps

After downloading and copying the option tree into your theme now Edit file or functions-admin.php (the Option-tree folder -> includes), is used to change the settings of data on option-tree, see the following picture:

1. Is used to adjust the position of menus and icons, I think the default is the best (theme.php), if you want to try another menu position, please replace theme.php with index.php or empty (”).
Example : index.php
'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'index.php' ),

Example : empty

'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', '' ),

2. Position is used to set the menu order.
'position' => apply_filters( 'ot_theme_options_position', __( '5', 'option-tree' ) ),

3. Is used to change page title.
'page_title' => apply_filters( 'ot_theme_options_page_title', __( 'This is Page Title', 'option-tree' ) ),

4. Is used to change menu name.
'menu_title' => apply_filters( 'ot_theme_options_menu_title', __( 'Azoncast-V2 Options', 'option-tree' ) ),

5. Is used to change menu icon
'icon_url' => apply_filters( 'ot_theme_options_icon_url', __( 'Icon Url', 'option-tree' )),

Comments & Responses

Comments are closed.