WordPress developer, consultant, nerd

Enabling the WordPress media trash feature

Working with media in WordPress is, for the most part, a fairly simple task; especially with the more recent improvements to the media manager. Deleting media items, however, can sometimes be a somewhat risky process as you are only presented with the option to Delete Permanently. This behaviour differs from working with posts and pages, as you are, by default, given the ability to Move to Trash before deciding whether or not you want to permanently delete the item.

Fortunately, there is a trash feature for the WordPress media manager and it can be enabled through one simple line of code;

// In wp-config.php
define('MEDIA_TRASH', true);

Enabling this feature will replace the Delete Permanently links with an aptly named Trash link. Any ‘trashed’ items will then appear in the media trash where you can later delete them permanently, should you wish to.

  • dogs2love

    Unfortunately this does´nt work in WP 4.7.2 any more…

    • http://philkurth.com.au Phil Smart

      I just tested this on a fresh install of WordPress 4.7.2 and the feature is still working.

  • dogs2love

    It´s not in wp-config.php – it shoult be added to wp-settings.php !

    Add it before this:
    // Include files required for initialization.
    require( ABSPATH . WPINC . ‘/load.php’ );

    • http://philkurth.com.au Phil Smart

      No, you should NEVER add anything to your wp-settings.php file. wp-settings.php is a core file that will be replaced on WordPress updated. wp-config.php includes the wp-settings.php file at the very bottom.

      This is exactly what the wp-config.php file is there for.

      Learn more about it here – https://codex.wordpress.org/Editing_wp-config.php

  • Richard Schmidt

    Hi,

    can someone check if this is working on WP 4.8? I don’t get the trash in the mediathek, maybe some hints?

    Thanks and Allbest

    Richard

    • Richard Schmidt

      Hi again,

      if I set “Media_Trash” in default-constants to true, it’s working. It’s a workaround but not a solution, maybe someone know whats happend?

      THX and allbest,

      Richard