programing

워드프레스 후크 사전사후 업데이트

batch 2023. 9. 13. 22:24
반응형

워드프레스 후크 사전사후 업데이트

워드프레스 플러그인을 쓰고 있습니다.게시 상태가 향후인 경우 게시 상태를 게시하도록 설정하고 있습니다.

저는 pre_post_update라는 하나의 후크를 알고 있습니다.

그러나 post_status를 변경할 수 있도록 post 관련 세부 정보 배열은 어디에 저장됩니까?

도와 주셔서 감사해요.

pre_post_update hook을 호출하는 함수가 wp-includes/posts의 1525행에 나타납니다.php:

do_action( 'pre_post_update', $post_ID );

보시는 것처럼 업데이트 중인 게시물의 아이디를 실행 시 통과합니다.거기서 우편물을 받으시려면, 그냥 전화를 하시면 됩니다.get_post(), 예:

function do_something_with_a_post($post_id, $post_data) {
     // now do something with $post_data
}
add_action('pre_post_update', 'do_something_with_a_post', 10, 2);

$post위의 변수는 여러분이 찾고 있는 게시물에 대한 다양한 속성을 모두 가진 개체를 참조해야 합니다.

언급URL : https://stackoverflow.com/questions/2260210/wordpress-hook-pre-post-update

반응형