Deleting a WordPress Plugin: How to Clean Up the Database Data It Leaves Behind

Affiliate disclosure v3.1
Affiliate disclosure v3.2 (mobile)

Deleting a WordPress plugin takes one button in the admin screen, but the tables and settings the plugin created often stay in the database. This site, too, still has 8 tables and 38 option rows left by an ad plugin and a comment plugin it removed long ago, as of 2026-10-09.

This guide goes in order, from deleting a plugin in the admin screen to cleaning up the shortcodes, folders and database data it leaves behind.

1️⃣ Deleting a Plugin in the Admin Screen

Under [Plugins] > [Installed Plugins], click [Deactivate] first, then click [Delete], which appears on the same row.

Deleting a WordPress plugin - admin page

If the plugin includes cleanup code, it runs at this point; if not, only the files are removed and the data stays.

2️⃣ Why Data Remains After Deleting

When WordPress deletes a plugin, it runs that plugin's [uninstall.php] file or the function registered with [register_uninstall_hook]. Removing the data is left to this code, so plugins with no such code, or code that removes only part of it, leave their tables and options behind.

Some developers leave data on purpose, so that settings come back as they were if the plugin is reinstalled. Some plugins, such as Wordfence, offer an option in their settings to delete the data as well, and the Polylang multilingual plugin offers the same option.

Deleting and deactivating a WordPress plugin - Wordfence plugin with a delete option
Wordfence plugin deletion option

3️⃣ How Leftover Data Affects the Site

Among leftover options, rows with [autoload] turned on are loaded into memory with the other settings every time a page opens. On this site, wpDiscuz's [wc_options] (15KB) and Advanced Ads' [advanced-ads-ab-module] (14KB) were rows like that.

Still, this site's autoload total is about 392KB and the leftover rows are about 39KB of it, which does not make a noticeable speed difference. WordPress's [Site Health] screen shows a warning when the autoload total exceeds 800KB.

After turning off autoload on the 23 leftover rows, Advanced Database Cleaner's [Autoload size] dropped from 391.52KB to 353.36KB.

Advanced Database Cleaner autoload size 391.52KB (before cleanup)
Advanced Database Cleaner autoload size 353.36KB (after cleanup)

Normally this is not a problem. Visitors who get cached pages do not go through PHP, so the autoload bundle is only loaded by requests that skip the cache, such as the admin screen, the first visit right after the cache is cleared, and bots. When many such requests arrive at once, each one unpacks the autoload bundle into memory, so the bigger a site's autoload grows, the faster server load climbs.

Options with autoload off and leftover tables are never read once the plugin is gone, so they do not affect speed; they only add to database size and backup size.

4️⃣ Cleaning Up What Is Left

Before touching the database, back it up in full first.

🔲 Shortcodes

Once a plugin is deleted, the shortcodes it placed in posts show up in the content as raw bracketed text. Until you edit each post, add the line below to your theme's [functions.php] so that the shortcode outputs nothing.

add_shortcode( 'pluginshortcode', '__return_false' );

This site, too, used about ten shortcodes from a table plugin, removed them one by one along with its tables when the plugin was deleted over a security issue, and has not used shortcodes since.

🔲 Plugin Folder

If a folder was not removed from the admin screen, delete it directly under [wp-content/plugins] over FTP, cPanel or SSH.

🔲 DB Tables and Rows (phpMyAdmin)

Most hosts provide phpMyAdmin.

WordPress phpMyAdmin - path after selecting a table

For leftover tables, find the tables with the plugin's name on the [Structure] tab and drop them. The screen below uses Yoast SEO as an example.

WordPress phpMyAdmin - finding and dropping a table on the Structure tab

For rows such as options, search with the [%] wildcard on the [Search] tab, as in [%yoast%].

WordPress phpMyAdmin - finding and deleting rows with Search 1
WordPress phpMyAdmin - finding and deleting rows with Search 2

Filtering once more with [Filter rows] confirms whether the rows relate only to Yoast SEO.

WordPress phpMyAdmin - finding and deleting rows with Search 3

Rows mostly remain in [wp_options], [wp_postmeta] and [wp_usermeta], and the [wp_] prefix in table names can differ from site to site. Deleting by name alone can remove rows other plugins use, so delete only rows you have confirmed belong to the plugin.

5️⃣ DB Cleanup Plugins

To clean up from the admin screen instead of phpMyAdmin, use Advanced Database Cleaner. This site uses it too, and it shows which plugin each option and table belongs to under [Belongs to], so you can tell which rows are safe to delete.

Rows whose [Belongs to] shows [Not scanned yet] are not unused rows; their owner is simply not known yet. On this site, many of the unfamiliar names turned out to be licenses and settings of plugins that are still active, such as Kadence Blocks Pro and WP Ghost, and deleting such rows deactivates the license or resets the settings.

So even for rows from a deleted plugin, do not delete them right away; turn off their autoload first. The values stay in place so you can undo it at any time, and if the site has no problems for a few days, delete them then.

Leftover options from a deleted plugin - autoload auto
Leftover options from a deleted plugin - autoload off

WP-Optimize can also delete leftover tables in its free version.

WP-Optimize plugin - deleting leftover database tables
WP-Optimize DB table deletion feature
Plugin (neon sign glowing on a stone wall)

🔢 FAQ & Recommended Content

WordPress only loads active plugins, so a deactivated plugin's code does not run when a page opens. But as long as its files stay on the server you still have to keep them updated, so delete the plugin if you do not plan to use it again.

Active plugins do not show [Delete], so click [Deactivate] first. If it still does not appear, check wp-config.php: if [DISALLOW_FILE_MODS] is set to true there, installing, updating and deleting plugins are all blocked. On multisite, only a super admin can delete plugins.

[wp plugin uninstall plugin-name --deactivate] deactivates the plugin, runs its cleanup code and deletes its files. [wp plugin delete] only deletes the files without running the cleanup code, so use uninstall if you want the data cleaned up too.

Files in the [wp-content/mu-plugins] folder are must-use plugins that always run without an activation step, so the admin screen has no [Delete] link for them. To remove one, delete its file from that folder directly over FTP or SSH.

ℹ️ Affiliate Disclosure
This site's content contains affiliate links. When a visitor buys a product or service through one of them, the site receives a commission from the seller. The amount the buyer pays(it goes down during event discounts ↓)does not go up. Posted prices, discounts, and stock reflect the time of writing and may differ, so confirm with the seller before buying. Products are chosen and reviewed by our own standards, and commissions do not affect the order or content of reviews.

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your humanity: 2   +   8   =