my wp insert post not working. In post_title and post_name he not save the variable. So at place of Service + variable , i get only "Service", why?
function mic_create_new_page() { global $ user_ID; $ new_post = array( 'post_title' => 'Service ' . $ secteur, 'post_content' => '[makeitseo-keyword]', 'post_status' => 'publish', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => $ user_ID, 'post_type' => 'page', 'post_name' => $ slugmic ); global $ wpdb; $ tableau_post = array (); $ tableau_post = mic_stock_in_array($ tableau_post); $ res = $ wpdb->get_results('select * from wp_secteurs'); foreach ( $ res as $ ville ) { $ id = $ ville->id_secteurs; $ secteur = $ ville->libelle; $ slugmic = strtolower(str_replace(" ","-",$ secteur))."-s". $ id ; if(!in_array(normalize($ slugmic), $ tableau_post)) $ post_id = wp_insert_post($ new_post); }
}