如果您是通过核心管理页面上传,WordPress很可能会上传文件,然后创建attachment
post--也就是说,带有attachment
岗位类型。所以save_post_attachment
胡克可能会帮你。
3362 /**
3363 * Fires once a post has been saved.
3364 *
3365 * The dynamic portion of the hook name, `$post->post_type`, refers to
3366 * the post type slug.
3367 *
3368 * @since 3.7.0
3369 *
3370 * @param int $post_ID Post ID.
3371 * @param WP_Post $post Post object.
3372 * @param bool $update Whether this is an existing post being updated or not.
3373 */
3374 do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
考虑到这个问题有多普遍,很难非常具体。