Get custom taxonomy for visual composer shortcode but not working?


I created a shortcode for visual composer to get terms of a custom taxonomy. But when I get them (for a category dropdown on visual composer’s backend editor) it’s not working.

enter image description here
My code:

$args1= array(
   ‘taxonomy’ => ‘danh_muc’, **// my custom taxonomy**
   ‘hide_empty’ => 0,
$danhmucs= get_terms($args1);
foreach ($danhmucs as $danhmuc) {
   $tendm=$danhmuc-> name;
   $iddm=$danhmuc-> term_id;
vc_map( array(
   “name” => __(“News”, ‘understrap’),
   “base” => “tintuc”,
   “class” => “”,
   “category” => ‘Content’,
   “icon” => “icon-wpb-application-icon-large”,
   “params” => array(
         “type” => “dropdown”,
         “holder” => “div”,
         “class” => “”,
         “heading” => “Danh mục”,
         “param_name” => “cat”,
         “value” => $inra, //**array taxonomy by name=> id**
         “description” => ‘Chọn danh mục BĐS cần hiện bài đăng’,

But when I change ‘taxonomy’ => ‘danh_muc’ to ‘taxonomy’ => ‘category’ it’s working fine!

I var_dump $inra with 2 cases: ‘taxonomy’ => ‘danh_muc’ and ‘taxonomy’ => ‘category’, The results are the same.

Thanks all!

, aminor1993 2 years 2020-01-12T08:42:22-05:00 0 Answers 78 views 0

Leave an answer