I wrote the following lines of code. It shows a dropdown menu with all available Wordpress categorys in the Wordpress customizer and can output the category slug. But instead of the slug I want to output the category id. Does anyone have an idea how to realize that?
$categories = get_categories();
$cats = array();
$i = 0;
foreach($categories as $category){
if($i==0){
$default = $category->slug;
$i++;
}
$cats[$category->slug] = $category->name;
}
$wp_customize->add_setting('wptimes_homepage_featured_category', array(
'default' => $default
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'wptimes_homepage_featured_category', array(
'label' => 'Hervorgehobene Kategorie',
'description' => 'Wähle hier die Kategorie aus, die du auf der Startseite hervorheben möchtest.',
'section' => 'wptimes_homepage',
'settings' => 'wptimes_homepage_featured_category',
'type' => 'select',
'choices' => $cats
)));