wordpress文章发布、更新、删除、回收站使用钩子函数挂载要触发的方法

add_action('publish_post','publish_article'); //挂钩 发布、更新文章时将函数挂载到publish_post上
function publish_article( $post_ID )
{
    return file_put_contents('123publish.txt',var_export($post_ID,true));
}
add_action('trash_post','trash_article'); //文章移入回收站 挂载触发
function trash_article($post_ID){
    return file_put_contents('123trash.txt',var_export($post_ID,true));
}
add_action('untrash_post','untrash_article'); //从回收站收回文章
function untrash_article($post_ID){
    return file_put_contents('123untrash.txt',var_export($post_ID,true));
}
add_action('before_delete_post', 'delete_article'); //删除文章
function delete_article($post_ID){
    $txt = "删除数据";
    return file_put_contents('123delete.txt',var_export($post_ID,true).var_export($txt,TRUE));
}

你可能感兴趣的:(wordpress文章发布、更新、删除、回收站使用钩子函数挂载要触发的方法)