I have the below code:
Here I declare the code for getting the category name and slug
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'taxonomy' => 'category'
);
$categories = get_categories($args);
$categories_name = array(); // here i get the category name
$categories_ids = array(); // here i get the category slug
foreach($categories as $category){
$categories_name[] = $category->name;
$categories_ids[] = $category->slug;
}
Here is the setting that is echoed in my back-end with the category name for the user to select
$this->settings['categoriesmain3'] = array(
'section' => 'general',
'title' => __( 'Select Right Block Category' ),
'desc' => __( 'Here you can select the main category for main right block.' ),
'type' => 'select',
'std' => '',
'choices' => array('$categories_name' => '$categories_ids') //I am trying to do
);
$settings = get_option('mytheme_options');
$my_choices_cat3 = $settings['categoriesmain3'];
I am trying to add in choices => the code array('$categories_name' => '$categories_ids')' but it doesn't work like that. In my example for manually adding the select field I have 'choices' => array('Choice 1' => 'choice1', 'Choice 2' => 'Choice 2'), so what is the correct syntax for the choices element where i want to add a dynamic list?