2011-05-05 4 views

Répondre

24

post_title définit le titre et post_name définit la limace. Ainsi:

// Create post object 
$my_post = array(
    'post_title' => 'How to make your diet success', 
    'post_name' => '7-ways-to-make-succes-Diet', 
    'post_content' => 'my content', 
    'post_status' => 'publish', 
    'post_author' => 1, 
    'post_category' => array(8,39) 
); 

// Insert the post into the database 
wp_insert_post($my_post); 
+0

Merci .. son fonctionnement. je ne remarque pas post_name .. – Andy

+0

Salut, est-il possible d'ajouter l'ID poste à la fin de post_name, de sorte que le slug généré ressemblerait à 'hello-world-123 'où 123 est l'ID poste inséré? – Anagio

+0

C'est ce que j'ai essayé mais en obtenant une erreur ''nom_post' => '$ title'. '-' $ pid ',' – Anagio

Questions connexes