0

I am getting the following errors while upgrading WordPress using Composer.

PHP Warning: Constant WP_CONTENT_DIR already defined in /var/www/html/my-website/wp-config.php on line 112 PHP Warning: Constant WP_CONTENT_URL already defined in /var/www/html/my-website/wp-config.php on line 11

Line 112 of my wp-config.php file contains the following code:

define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/wp-content' ); 

And, Line 113 of my wp-config.php file contains the following code:

define( 'WP_CONTENT_URL', WP_HOME . '/wp-content' );

And when I do echo 'WP_CONTENT_URL: ' . WP_CONTENT_URL; I am getting following output and which is pointing correctly to my wp-content folder.

WP_CONTENT_URL: http://localhost/my-website/wordpress/wp-content

enter image description here

enter image description here

1 Answer 1

0

You've got that constant defined in two places. The error message tells you where it is first defined:

     Warning: Constant WP_CONTENT_URL 
already defined in 
/var/www/html/my-website/wp-config.php on line 11

Look at line 11 of the wp-config.php file. I'd bet that you'll find that constant defined there.

5
  • I have attached the screenshot of the error.log file in the question.
    – tek bhatt
    Aug 19, 2023 at 18:17
  • Its a typo actually it's 113.
    – tek bhatt
    Aug 19, 2023 at 18:24
  • OK. Constant defined on line 113. Then defined again somewhere else (after line 113). Do a search for the constant name. It will be in the wp-config.php file, or in another file called later. Actually, two constants are being defined twice. Search your files. Aug 20, 2023 at 1:50
  • I have searched the whole codebase for the constant WP_CONTENT_URL and it looks like it's not defined elsewhere. I have attached the screenshot of all search results of the WP_CONTENT_URL constant in above question.
    – tek bhatt
    Aug 20, 2023 at 7:53
  • I can't tell if you also searched the plugins folder. Or that you have tried disabling the plugins (any and all), or trying a different theme (one of the 'twenty' themes) to see if the error still occurs. The error message indicates that there are two 'define' statements for those variables. So it's in there somewhere: the core WP files, the themes folder, or the plugins folder. It's also possible that the extra define is in a hacked files - I've seen PHP code in an ICO file, for instance. Search every single file, starting in the site root. Aug 20, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.