Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?

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.

5 s
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:

https://wordpress.org/support/topic/php-7-3-errors/#post-12720824

Leave a Comment