Saving category as insert post

The array for post_category needs to be an array of integers, not a string, and that’s what you are getting from the $_POST[‘cat’] the way you have it written. Change the value in the option to the category id instead.

Add php function into .js file (for tinyMCE button)

To ajax this function you have hook it, so your function will be like this : function write_cat_list($cat){ $cats = get_categories(‘hide_empty=0’); if($cats) : $tinyMCE_list = array(); foreach ($cats as $cat) : $tinyMCE_list[] = array( ‘text’ => $cat->name , ‘value’ => $cat->term_id ); //write_cat_list($cat->term_id); endforeach; $jscode = json_encode($tinyMCE_list); //to convert from array to opject echo $jscode; … Read more