How to add categori selection option in theme option?
-
I am trying to add a category option in my wordpress theme using option tree. I am using this code in theme-option.php
<?php add_action( 'admin_init', 'custom_theme_options', 1 ); function custom_theme_options() { $categories = get_categories('hide_empty=0&orderby=name'); $wp_cats = array(); foreach ($categories as $category_list ) { $wp_cats[$category_list->cat_ID] = $category_list->cat_name; } $saved_settings = get_option( 'option_tree_settings', array() ); $custom_settings = array( 'sections' => array( array( 'id' => 'general', 'title' => 'Home Page Settings' ) ), 'settings' => array( array( 'id' => 'Great-Product', 'label' => 'Great Product', 'desc' => 'select great Product category', 'type' => 'select', 'section' => 'general', 'std' => 'Choose a category', 'options' => $wp_cats ) ) ); if ( $saved_settings !== $custom_settings ) { update_option( 'option_tree_settings', $custom_settings ); } } ?>
But it is not showing any category. Where is my fault? Please tell me.
- The topic ‘How to add categori selection option in theme option?’ is closed to new replies.