admin管理员组文章数量:1390564
I am creating a plugin in which a user will submit their email address and favourite tags. When publishing a new post, if the post has tags similar to the user's favourite tags, an email will be sent to the user. For this I need to compare new post tags with the user's favourite tags.
On basis of its definition get_the_tags($postId)
should return an array of post_tags
but it doesn't. I don't know what to do!
add_action('publish_post', array( $myClass ,'wp_send_emailToUser' ), 10, 2);
class customFunction{
function wp_send_emailToUser( $postId, $post ) {
$posttags = get_the_tags($postid);
if ($posttags) {
//...do sth
}else{
error_log( "@ tags are empty,post id={$postId}" );
}
}
The new post I published has some tags but it goes to the else part and print error_log("@ tags are empty, post id={$postId}");
in my debug.log file. I searched a lot but didn't find anything!
I am creating a plugin in which a user will submit their email address and favourite tags. When publishing a new post, if the post has tags similar to the user's favourite tags, an email will be sent to the user. For this I need to compare new post tags with the user's favourite tags.
On basis of its definition get_the_tags($postId)
should return an array of post_tags
but it doesn't. I don't know what to do!
add_action('publish_post', array( $myClass ,'wp_send_emailToUser' ), 10, 2);
class customFunction{
function wp_send_emailToUser( $postId, $post ) {
$posttags = get_the_tags($postid);
if ($posttags) {
//...do sth
}else{
error_log( "@ tags are empty,post id={$postId}" );
}
}
The new post I published has some tags but it goes to the else part and print error_log("@ tags are empty, post id={$postId}");
in my debug.log file. I searched a lot but didn't find anything!
1 Answer
Reset to default 0wordpress.stackexchange/questions/266999
I found the problem in the above link , I should use set_object_terms becaus tags will not be with the post in publish_post.
本文标签: plugin developmentgetthetags doesn39t works
版权声明:本文标题:plugin development - get_the_tags doesn't works? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744590551a2614462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论