On my HostGator shared hosting with a CPanel option to set PHP per domain, if I turn on PHP 7.3 (or other 7.x versions) for my existing blog I get an error page:

Warning: Use of undefined constant WP_CONTENT_DIR – assumed ‘WP_CONTENT_DIR’ (this will throw an Error in a future version of PHP) in /my_site/public_html/wp-includes/load.php on line 141 Your PHP installation appears to be missing the MySQL extension which is required by WordPress

If I Google this, all the advice is about how to install mysqld, but it's surely already installed as doing a fresh install of WordPress on a separate sub-domain works perfectly under PHP 7.3, so I must be missing something in my older site's WordPress wp-config.php, perhaps. Looking at working and failing versions, though, I cannot see an obvious difference.

  • How did you solve this? I have exactly the same problem. Commented Jul 17, 2020 at 13:42
  • @TheOddAbhi I should update - it turned out I had an .htaccess in my root directory - the one above public_html - that had PHP 7.1-related commands that was mucking up the CPanel options. I've got a suspicion that I've been like that ever since I started with HostGator and they did an install for me from my previous host.
    – Ken Y-N
    Commented Jul 18, 2020 at 16:22

5 Answers 5


Here's what worked for me: My Hostgator WordPress site was throwing the same error until I commented out the top-level .htaccess file. Like so:

I commented out the PHP default settings

My website is a subdomain, so it had it's own .htaccess, so that's where the php version was specified (cpanel did this automatically). I didn't have to edit wp-config.php or anything else.

In the comments of this post is where I found this solution:



Ensure WP_CONTENT_DIR is defined in your wp-config.php file. It will be the path to your wp-content directory.

define('WP_CONTENT_DIR', '/path/to/wordpress/wp-content');
  • Thanks. This solved the issue for me. Not completely, but removed this error. Commented Jul 17, 2020 at 13:51

Normally, the WP_CONTENT_DIR entry is defined in the https://developer.wordpress.org/reference/files/wp-includes/default-constants.php/ file (which is loaded after wp-settings.php):

     if ( ! defined( 'WP_CONTENT_DIR' ) ) {
            define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); 
            // No trailing slash, full paths only - WP_CONTENT_URL is defined further down.

This will set the WP_CONTENT_DIR to default of your site's 'wp-content' folder, unless you (or someone/something) has defined this previously in the wp-config.php with a command like this:

define('WP_CONTENT_DIR', '/path/to/wordpress/wp-content');

In a 'fresh'/default install, there should not be that DEFINE in the wp-settings file. Perhaps you have a plugin or function that has moved the content folder to a new location as a 'security' method (although it is debatable whether that is useful -'security by obscurity' doesn't work all that well) and modified the WP_CONTENT_DIR variable value.

So check your wp-settings.php file for that DEFINE statement. Remove it (unless you really want your wp-content files somewhere else), or look for a plugin in your site that is doing that.


In my case, there were two .htaccess files running simultaneously (one from the "public_html" and one above the root directory), and it was causing the conflict. I removed the file, and it worked. I was able to get this fixed with my Wordpress version upgrade issue.

Here's the original post of this solution: https://iiiji.com/fix-php-upgrade-error-whm-cpanel/


I just updated the PHP version 7.0 to 7.4 from Multi Php Editor for my website and I found the Use of undefined constant WP_CONTENT_DIR – assumed ‘WP_CONTENT_DIR’

After that, I degrade the version to 7.0 and got this error

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Again I upgraded to 7.4

How I solved the error? Just deleted the .htacess file and refresh. All worked fine for me.


  • That sounds strange to me. What was in the .htaccess file that broke PHP? I don't think you can disable the PHP MySQL extension from an .htaccess can you?
    – Rup
    Commented Dec 17, 2020 at 8:25

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.