Warm tip: This article is reproduced from stackoverflow.com, please click
hook php wordpress

When I publish a new post in Wordpress, I cannot get the tags of the post

发布于 2020-04-07 23:15:56

tags come up when i update a post. When I publish a new post for the first time, I cannot get the tags. How do I get the tags when I publish for the first time?

add_action('save_post', 'bunu_worker', 10, 2);

function bunu_worker($ID, $posts) {
    global $wp,$post;

    $postge = get_the_tags($ID);        

    $arkadaslar = 'my@mymail.com';
    $headers = array('Content-Type: text/html; charset=UTF-8');
    wp_mail( $arkadaslar, "subject mesage", print_r($postge, true), $headers , array() );

    return;
}
Questioner
SemsiPasa
Viewed
68
SemsiPasa 2020-02-04 05:30
add_action ('save_post', 'job_worker', 10, 2); 

I could not get the tags because the DB record is late in the process.

The hook below works after DB records occur so I can get the tags.

add_action ('set_object_terms', 'job_worker', 10, 2);