• Resolved wordpressnetwork

    (@wordpressnetwork)


    Hey,

    I want to delete products in the trash automtically. I already put this into my wp-config:

    define(‘EMPTY_TRASH_DAYS’, 1 ); //Integer is the amount of days

    But they just stay there. Deleting them manually is working. Is there a specific thing I have to look out for to not only delete posts but products automatically?

    Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @wordpressnetwork,

    The code you’ve added to your wp-config file is correct for automatically deleting posts after a certain number of days. However, for WooCommerce products, you would need to use a different approach as they are a custom post type.

    You may consider using a plugin like WP-Optimize. This plugin cleans the database and allows you to set up automatic cleanups, including removing trashed posts, pages, and products.

    You can also try using Smart Manager for WooCommerce or Change Empty Trash Time plugin.

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

    Thread Starter wordpressnetwork

    (@wordpressnetwork)

    Hi Shameem,

    thanks for your answer.

    I think there is a misunderstanding, however. My problem lies in the fact that the line

    define(‘EMPTY_TRASH_DAYS’, 1 );

    does not delete my WooCommerce products in trash as it should be as far as I understand. The same is stated in the first two links you provided – the discussion is only about how to differentiate between certain post types when you *don’t* want them to be treated normally.

    I also tried the Empty Trash Time plugin already – no function. When I use the automatic delete function of the WP Optimize plugin, however, the products get deleted. Support states that there is no difference normally between the stuff in trash. I cannot use that plugin though because it interfered with my existing caching setup.

    So the links from Stackexchange and Stackoverflow as well as WP Optimize support say the one line in wp-config should delete all post types. You say otherwise and in reality it only works with WP Optimize which I cannot use.

    Do you have any idea what the probem could be? Or do you have another line for the wp-config, maybe with this method the WooCommerce products need to be addressed seperately?

    Thanks a lot!

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @wordpressnetwork

    Thanks for the correction and further details.

    define(‘EMPTY_TRASH_DAYS’, 1 );

    Could you try adding it to your child theme’s functions.php instead of the wp-config.php file and see if it works? More info: https://www.wpbeginner.com/wp-tutorials/how-to-automatically-empty-your-wordpress-trash/#aioseo-method-1-automatically-empty-wordpress-trash-with-wpcode-recommended

    If the issue persists, it could be related to server-side caching or a cron job not running correctly. In this case, you might need to contact your hosting provider for further assistance.

    Furthermore, if you prefer to address WooCommerce products separately in the wp-config.php file, unfortunately, there isn’t a direct way to do this as the EMPTY_TRASH_DAYS constant is a global setting in WordPress and applies to all post types.

    I wish I could help more, but hopefully, this gets you going in the right direction to get the job done.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to automatically delete products from trash?’ is closed to new replies.