{$new_status}_{$post->post_type}

ACTION wp-includes\post.php (ligne 5885) github
Fires when a post is transitioned from one status to another. The dynamic portions of the hook name, `$new_status` and `$post->post_type`, refer to the new post status and post type, respectively. Possible hook names include:  - `draft_post`  - `future_post`  - `pending_post`  - `private_post`  - `publish_post`  - `trash_post`  - `draft_page`  - `future_page`  - `pending_page`  - `private_page`  - `publish_page`  - `trash_page`  - `publish_attachment`  - `trash_attachment` Please note: When this action is hooked using a particular post status (like 'publish', as `publish_{$post->post_type}`), it will fire both when a post is first transitioned to that status from something else, as well as upon subsequent post updates (old and new status are both the same). Therefore, if you are looking to only fire a callback when a post is first transitioned to a status, use the {@see 'transition_post_status'} hook instead.

Paramètres

Entrée :
$post->ID, $post, $old_status
Sortie :
@param int     $post_id    Post ID.
@param WP_Post $post       Post object.
@param string  $old_status Old post status.

Utilisation

// Ajouter une fonction au hook action '{$new_status}_{$post->post_type}'
add_action('{$new_status}_{$post->post_type}', 'ma_fonction_personnalisee', 10, 1);

function ma_fonction_personnalisee($post->ID, $post, $old_status) {
    // Votre code ici
    error_log('Hook {$new_status}_{$post->post_type} déclenché');
}

Actualités

Chargement des actualités...