I am trying to get the categories of my custom post type in functions.php But it not return any value, when i run this query in any theme file it work fine. Here is my code
function get_destinations(){
$args = array(
'type' => 'accomodation',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'facilitie',
'pad_counts' => false
);
$categories = get_categories($args);$destinations = array();
foreach ($categories as $cat) {
if($cat->cat_name != ''){
$destinations[$cat->cat_name] = $cat->cat_name;
}
}
return $destinations;
}
I am using this code to add meta field
, now i have to pass the category to select
tag which is
$my_meta2->addSelect($prefix.'select_field_id',get_destinations(),array('name'=> 'Select Destination'));
The original code is like this, they pass the value in array.
$my_meta->addSelect($prefix.'select_field_id',array('selectkey1'=>'Select Value1','selectkey2'=>'Select Value2'),array('name'=> 'My select ', 'std'=> array('selectkey2')));
But not getting any value, Any idea where i am wrong. Thanks