Inserts or updates a post in the database. If the `$postarr` parameter contains an 'ID', the corresponding post will be updated. If not, a new post will be created using the values provided. You can set the post date manually, by setting the values for 'post_date' and 'post_date_gmt' keys. You can close the comments or open the comments by setting the value for 'comment_status' key.
$postarr, $wp_error = false, $fire_after_hooks = true
Sortie :
@param array $postarr {
@param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
@param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true.
@return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
// Utilisation de la fonction wp_insert_post
$result = wp_insert_post($postarr, $wp_error = false, $fire_after_hooks = true);
if ($result) {
// Votre logique ici
}
Chargement des actualités...