I am building a theme and for the Theme Settings Page I followed this tutorial: http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/
What I want now is to have a multi-checkbox with every category. This is what I should have:
$options[] = array(
"section" => "zzz",
"id" => HS_SHORTNAME . "_multicheckbox_inputs",
"title" => __( 'Multi-Checkbox', 'hs_textdomain' ),
"desc" => __( 'Some Description', 'hs_textdomain' ),
"type" => "multi-checkbox",
"std" => '',
"choices" => array( __('Category 1','hs_textdomain') . "|category1", __('Category 2','hs_textdomain') . "|category2", __('Category 3','hs_textdomain') . "|category3")
);
However I've tried multiple options but none of them gives me exactly as shown above. I think the answer is close to get_categories() function with no luck. Also tried:
function my_list_cats() {
$cats = get_categories();
foreach($cats as $cat) {
$catsArray[] = __('' . $cat->cat_name . '','hs_textdomain') . "|" . $cat->category_nicename . "";
}
echo implode(', ', $catsArray);
}
And then:
"choices" => array(my_list_cats())
But no luck. Does anyone know a solution? Thank you very much
implode
the results in your function; try toreturn
the result insteadecho