Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • What sort of debugging have you done? Have you verified that $post_ids gets populated? Have you verified the values for $expire_date and $todays_date are correct? Have you verified that it passes the if condition and wp_set_post_terms is called? Have you looked at what wp_set_post_terms returns? Commented Dec 1, 2018 at 17:46
  • Sorry - possibly the most important thing I forgot to add - $post_ids is returning an empty array() !! Commented Dec 1, 2018 at 17:51
  • 1
    field should be term_id in a tax query, not id. Commented Dec 1, 2018 at 17:56
  • Thank you, $post_ids is still empty though I'm afraid - no errors or notices being thrown up Commented Dec 1, 2018 at 18:17
  • 1
    Try changing get_posts to new WP_Query, then you can inspect $post_ids->request after the query is run and you'll see the SQL being sent to the database. Commented Dec 1, 2018 at 18:33