wp_insert_post() does not support variable
There is no difference in PHP between a string and a variable set to a string, so the problem is elsewhere. Most likely it is with passing the slug argument as mentioned in the codex for wp_insert_term: https://codex.wordpress.org/Function_Reference/wp_insert_term : If ‘slug’ argument exists then the slug will be checked to see if it is not … Read more