How to select category on if function
According to the documentation, transition_post_status action receives only 3 parameters ($old_status, $new_status, and $post). There is no $category_id parameter, but as post object is available for you, you are able to get post category using this post object. In your case, for the if statement, it’s better to use has_category() function where you can pass … Read more