Title: Plugin Fixes: Category Replace, Add and Remove
Last modified: March 29, 2018

---

# Plugin Fixes: Category Replace, Add and Remove

 *  [discotoast](https://wordpress.org/support/users/discotoast/)
 * (@discotoast)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/plugin-fixes-category-replace-add-and-remove/)
 * First of all what a great plugin.
 * We did however notice some issues right away – none of the Category expiry methods
   were working even though the Debug Log was indicating that it was successful.
 * We went ahead and had a look at the code in post-expirator.php and are happy 
   to report that we were able to correct the bugs.
 * **Those of you having similar problems with the plugin can use the following 
   3 line replacements to correct issues with the category expiration methods:**
 * **1) Replace Line 691:**
    `if (wp_update_post(array('ID' => $id, 'post_category'
   => $category)) == 0) {`
 * _**with:**_
    `if (wp_set_post_categories($id, $category, false) == false) {`
 * **2) Replace Line 722:**
    `if (wp_update_post(array('ID' => $id, 'post_category'
   => $merged)) == 0) {`
 * _**with:**_
    `if (wp_set_post_categories($id, $merged, true) == false) {`
 * **3) Replace Line 758:**
    `if (wp_update_post(array('ID' => $id, 'post_category'
   => $merged)) == 0) {`
 * _**with:**_
    `if (wp_set_post_categories($id, $merged, false) == false) {`
 * What we’re doing here is using the wp_set_post_categories function to apply the
   categories, rather than the wp_update_post function used in the plugin, then 
   checking whether it returns false rather than 0 after execution in the case of
   failure.
 * We hope this helps some of you who may be experiencing similar issues.
 * Cheers,
    Cameron [Discotoast Inc.](http://discotoast.com/)

Viewing 1 replies (of 1 total)

 *  [n40road](https://wordpress.org/support/users/n40road/)
 * (@n40road)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/plugin-fixes-category-replace-add-and-remove/#post-10134093)
 * I’m having this exact problem, and these code changes did not solve it. Any other
   suggestions? Plugin worked fine, then didn’t. No changes or updates performed.
   Categories no longer get replaced even though the log indicates success.
 * Thanks in advance.

Viewing 1 replies (of 1 total)

The topic ‘Plugin Fixes: Category Replace, Add and Remove’ is closed to new replies.

 * ![](https://ps.w.org/post-expirator/assets/icon-256x256.png?rev=3118683)
 * [Schedule Post Changes With PublishPress Future: Unpublish, Delete, Change Status, Trash, Change Categories](https://wordpress.org/plugins/post-expirator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-expirator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-expirator/)
 * [Active Topics](https://wordpress.org/support/plugin/post-expirator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-expirator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-expirator/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [n40road](https://wordpress.org/support/users/n40road/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/plugin-fixes-category-replace-add-and-remove/#post-10134093)
 * Status: not a support question