so I am engaged on a code to take knowledge from an array and put it in a customized taxonomy utilizing wp_insert_tem, however the knowledge will not go in. that is the json i wish to fetch, that is from a url
{
"genres": [
{
"name": "Military"
},
{
"name": "Sci-fi"
},
{
"name": "Shounen"
}
],
}
that is the code i made
$end result = file_get_contents($url);
$array = json_decode($end result, true);
foreach($array['genres'] as $gen){
wp_insert_term(
$gen["name"],
"genres",
array(
"description" => "",
"slug" => sanitize_title($gen["name"]),
),
);
}
please assist me