Send push when new post is published in a certain category

Question

I’m trying to develop a plugin which send a push notification to an app users, when a new post is published on a certain category.
I’m trying with the hook save_post, but when the hook is fired, the post has no categories.
I try in_category(2) function, but it always return false.
I try wp_get_post_categories($post_id) but always resolve to no categories and the same with wp_get_post_terms($post_id, 'category')

I dont know if save_post hook is the correct, I think it’s fired before the categories are asociated to the post.

How I know if the post is published in a certain category?

0
, , RoberV 8 months 0 Answers 86 views 0

Leave an answer