phpfunctiondropdowncategories

How add select dropdown category list to theme options


I have custom options theme in functions.php and it is a primary codes . I want to use select option to display all categories list and select one instead insert category ID

$themename = "تالار وردپرس";
$shortname = "shortname";
$categories = get_categories('hide_empty=0&orderby=name');
$all_cats = array();
foreach ($categories as $category_item ) {
$all_cats[$category_item->cat_ID] = $category_item->cat_name;
}
array_unshift($all_cats, "انتخاب دسته بندي");
/* ---------------------------------------------------------
تعريف آرايه هاي تنظيمات
----------------------------------------------------------- */
$theme_options = array (
    array( "name" =>" تنظيمات" . $themename,
    "type" => "title"),


        /* ---------------------------------------------------------
    تنظيمات اسلاید
    ----------------------------------------------------------- */
    array( "name" => "تنظیمات اسلاید بالای سایت",
    "type" => "section"),
    array( "type" => "open"),   
    array( "name" => "دسته بندی مطالب اسلاید",
    "desc" => "ابتدا افزونه wp_show_id را نصب کنید سپس آی دی دسته بندی مورد نظر خود را در این بخش که با نام پیشنهادی ما می باشد قرار دهید",
    "id" => $shortname."_catslide",
    "type" => "text",
    "std" => ""),
      array( "type" => "close"),   

Solution

  • I found the Code

    array( "name" => "تنظیمات اسلاید بالای سایت",
        "type" => "section"),
        array( "type" => "open"),   
        array( "name" => "دسته بندی اسلاید شو",
        "desc" => "لطفا یک دسته بندی را برای نمایش مطالب منتخب انتخاب کنید",
        "id" => $shortname."_catslide",
        "type" => "select",
        'section'  => 'general',
        "std" => "",
        'options' => $all_cats),
          array( "type" => "close"),