With define('WP_DEBUG', true);
in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php
:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php
in order to define the constant in the proper place, which is wp-config.php
.
How should I define this constant properly, without editing default-constants.php
, which risks being overwritten during an upgrade?
With define('WP_DEBUG', true);
in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php
:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php
in order to define the constant in the proper place, which is wp-config.php
.
How should I define this constant properly, without editing default-constants.php
, which risks being overwritten during an upgrade?
2 Answers
Reset to default 4When defining any WordPress constants in wp-config.php you need to do it before this line:
require_once( ABSPATH . 'wp-settings.php' );
That line loads many of WordPress’s default constants, and if you haven’t already defined them yourself then they’ll be defined in that line, meaning that any of them that you try to define after this line will have already been defined.
It means that the constant EMPTY_TRASH_DAYS
has been defined twice. You need to check and remove the second definition of the same constant.
It may be that it's been defined somewhere else. So search all the files of WordPress using grep
, find
or some advanced text editor like Sublime Text
index.php
(in install root, not your theme) ->wp-blog-header.php
->wp-load.php
->wp-config.php
. That notice is telling you where it's attempting to set the constant a 2nd time. It seems very strange to see that error that early in the process where only core files have been loaded. I would start by switching to a default theme and disabling all plugins, check if error is still present, then re-enable one-by-one. – Milo Commented Oct 25, 2018 at 3:45default-constants.php
the notice disappears. I've edited the question to include this updated information. However, the problem still isn't fully resolved, in that I shouldn't have to editdefault-constants.php.
– Kit Johnson Commented Oct 25, 2018 at 11:26require_once( ABSPATH . 'wp-settings.php' );
. Is yourdefine( 'EMPTY_TRASH_DAYS', 30 );
before this line? – Jacob Peattie Commented Oct 25, 2018 at 11:33