Term Meta Data were added to WordPress core when WP 4.4 was released. Term Meta Data can be used by developers to easily add meta data to taxonomy terms like categories and tags. But not all sites properly upgraded to use term meta data.
Term Meta Data is stored in the wp_termmeta table. The unlucky sites that failed to upgrade properly skipped the installation of wp_termmeta into their database. This can cause a lot of hidden problems.
Plugins and themes that use Term Meta Data will either break when they try to read or write data to the missing meta tables or they appear to work until you notice something is not quite right with the site.
The easy solution to install wp_termmeta is to upgrade to WordPress 4.5.
WordPress 4.5 is due to be released 12th April 2016. You are in luck if you cannot wait until April 12 because we can easily beta test WordPress 4.5…
Symptoms of missing database tables
- Web pages load slower than expected
- Plugins break or only partially function
- Themes break or some features cease to work
- Plugin, theme and post settings do not save
- WordPress ‘White Screen of Death’ shows when settings are saved
- Plugins cannot be activated. WordPress dies when you try to activate them
- WordPress multisite activation throws a database connection error message
- Web server error logs show thousands of “_termmeta table missing” SQL errors
- The settings page for some plugins doesn’t load
- Some pages do not load on the front of the website
When the wp_termmeta table is missing you will see error messages similar to these ones in your server’s error_log:
WordPress database error Table ‘wp_termmeta’ doesn’t exist for query SELECT term_id, meta_key, meta_value FROM wp_termmeta WHERE term_id IN (14) ORDER BY meta_id ASC made by require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/twentyfifteen/page.php’), get_template_part, locate_template, load_template, require(‘/themes/twentyfifteen/content-page.php’), the_content, apply_filters(‘the_content’), call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, em_get_events_list_shortcode, EM_Events::output, EM_Event->output, EM_Event->get_categories, EM_Categories->__construct, get_the_terms, wp_get_object_terms, update_termmeta_cache, update_meta_cache WordPress database error Table 'wp_termmeta' doesn't exist in engine for query SHOW INDEX FROM wp_termmeta WHERE Column_name = 'meta_key' made by wp_upgrade, pre_schema_upgrade WordPress database error Table 'wp_termmeta' doesn't exist in engine for query SELECT term_id, meta_key, meta_value FROM wp_termmeta WHERE term_id IN (51,52,53,54,2,55,56,57,58,59,60,61,105,106,107,108,109,110,111,62,63,64,65,66,67,68,69,70,71,112,72,73,113,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,104) ORDER BY meta_id ASC made by require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), MainWP_Child->parse_init, MainWP_Child->getSiteStats, get_categories, get_terms, update_termmeta_cache, update_meta_cache
The key section of the error message that tells your the wp_termmeta table is missing is
WordPress database error Table ‘wp_termmeta’ doesn’t exist for query SELECT term_id, meta_key, meta_value FROM
A temporary upgrade to WordPress 4.5 beta or to a later version will force WordPress to create the missing database tables.
How to Upgrade to a Beta Version
Upgrade to a beta version of WordPress by installing the WordPress Beta Tester plugin from the WordPress plugin repository. Activate the plugin then navigate to Dashboard > Updates and click ‘Update Now’.
The missing database tables are created during the upgrade process.
After the tables have been created you can downgrade to the current stable WordPress version, currently WP 4.4.2. To downgrade just disable the WordPress Beta Tester plugin then visit Dashboard > Updates and click ‘Reinstall Now’.
Deactivate and reactivate all active plugins and the active theme if missing database table errors continue to show in server logs.
I only recently paid attention to problems caused by the wp_termmeta table not being found in the databases of my sites. I had seen SQL errors in my server logs but hadn’t noticed any issues caused by the missing table. Few plugins and themes that I use currently make use of term meta data in a way that causes errors to show persistently.
The plugin that made me notice the bug was WP All Export. The plugin tried to access the missing wp_termmeta table and instead of giving me a nice export file to import into another website, WP All Export presented me with a beautiful White Screen of Death and megabytes of error messages in my server logs.
I’d like to make it clear, though, that WP All Export was not at fault. WordPress had failed to create the wp_termmeta tables when I upgraded to WP 4.4.
The biggest headache the missing table created for me was when I switched a sub domain multisite to a subdirectory multisite. Just one missing database table caused WordPress to show the ‘Error Establishing Database Connection’ warning. The database existed. The site worked when multisite was disabled. The site worked when sub domain sites were enabled. Switching the network to use sub directory sites killed WordPress.
Wasn’t until I had fixed the problem with WP All Export that I put two and two together and realized the extent of the problems caused.
I tried to create the tables by
- Running the WordPress built in database optimization and repair tool. The tool told me the tables were missing but didn’t offer to install them.
- Reinstalling my current version of WordPress. That didn’t help either. WordPress said the reinstallation had been successful but clearly it wasn’t.
- Launching the WordPress upgrade script by navigating to wp-admin/upgrade.php failed to force WordPress to create the missing table too.
The only simple solution that worked, and I tried this as a long shot, was to temporarily upgrade to WordPress 4.5 beta.
I could have manually run an SQL query to create the tables and that would have been my next step but I prefer WordPress to do the work where possible.
Would be nice if the WordPress maintenance tools optimized, repaired AND fixed missing database tables.