I need wordpress category as drop down . So far my code

function cat_drop_down(){
  $categories_array = array();
  $categories = get_categories();
    foreach( $categories as $category ){
      $categories_array[] = $category->term_id;
    }
  return $categories_array;
}

This renders drop down perfectly but its not passing the category id . Its rendering html like this

<select data-setting="tab_title">               
   <option value="0">2</option>             
   <option value="1">14</option>                
   <option value="2">1</option>             
</select>

So I am only getting 0,1,2 values instead of 2,14,1 that category id’s.
What am I doing wrong?

Read more here: WordPress Drop down category as array for using in page builder


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: