delete_post
最后更新于:2021-11-26 06:09:20
do_action( ‘delete_post’, int $postid, GC_Post $post )
Fires immediately before a post is deleted from the database.
参数
- $postid
-
(int)
Post ID. - $post
-
(GC_Post)
Post object.
源文件
文件: gc-includes/post.php
add_action( 'admin_init', 'gcdocs_codex_init' ); function gcdocs_codex_init() { add_action( 'delete_post', 'gcdocs_codex_sync', 10 ); } function gcdocs_codex_sync( $pid ) { global $gcdb; $query = $gcdb->prepare( 'SELECT post_id FROM codex_postmeta WHERE post_id = %d', $pid ); $var = $gcdb->get_var( $query ); if ( $var ) { $query2 = $gcdb->prepare( 'DELETE FROM codex_postmeta WHERE post_id = %d', $pid ); $gcdb->query( $query2 ); } }