Custom Post Type Cleanup

Plugin Banner

Custom Post Type Cleanup

by keesiemeijer

Download
Description

Custom post type posts are left in the database if a post type is no longer registered (in use).

Plugins and themes can (without you knowing) use custom post types as a way to store data. These posts stay in the database forever if they’re not cleaned up by the plugin/theme itself upon deletion.

There are a lot of plugins that clean your database (by removing revisions, drafts etc.), but I haven’t found one that does a cleanup of unused post type posts.

This plugin provides an easy way to detect and remove posts from post types that are no longer in use. The settings page for this plugin is at wp-admin > Tools > Custom Post Type Cleanup.

Note: The proper WordPress delete function wp_delete_post is used instead of running a direct MySQL query to delete the posts. This way all associated post data (comments, post meta etc.) are also deleted from the database.

Since version 1.2.0 you can re-register unused custom post types for a limited period of time. This allows you to inspect and delete the posts like you would normally (in the wp-admin).

Follow these instructions to install the plugin.

  1. In your WordPress admin panel, go to Plugins > New Plugin, search for “custom post type cleanup” and click “Install now”.
  2. Alternatively, download the plugin and upload the contents of custom-post-type-cleanup.zip to your plugins directory, which usually is /wp-content/plugins/.
  3. Activate the plugin
  4. Go to wp-admin > Tools > Custom Post Type Cleanup and see if there are unused custom post type posts in the database.
  1. Plugin page

    Plugin page

  2. Plugin page after re-registering unused custom post types.

    Plugin page after re-registering unused custom post types.

  3. Plugin page after cleaning up all unused post type posts

    Plugin page after cleaning up all unused post type posts

I'm glad someone created this plugin

By Slava Abakumov (slaFFik) on November 29, 2024

So I didn't have to 🙂

Awesome little handy tool to clean up old sites from obsolete CPTs and their post meta.

I wish it also supported custom taxonomies that were registered for those obsolete CPTs.

Great plugin

By designituk on May 23, 2024

Great plugin works perfectly

perfect! just what was needed 🙏

By rothschild86 on May 16, 2024

Thank you!

Very simple and working...

By tenserd on May 7, 2024

Its a really simple to use plugin and working right out of the box. A nice feature would be (if that is possible at all) to clean up abandoned taxonomies, too.

Thx for this nice plugin!

An amazing plugin for Custom Post Types

By Manou Allou (manouallou) on April 23, 2024

What a useful, little plugin! It helps clean up the database and keep it clean from old and obsolete CPTs.

Bravo to the developer who also swiftly updated it to the latest version shortly after my support request. What else can you ask for?

It worked for me too

By nene (wpdreamer) on May 14, 2023

Worked also for me today, hope it gets updates and keeps working, really usefull plugin.

Nice Job!!! Remove a Bloat from Database

By RK (rirgang) on September 26, 2022

This is an extremely useful plugin. It removes thousands of uselessly accumulated posts that bloat the database of plugins that are no longer used.

This is just amazing

By m4nuelgraph on July 19, 2022

This is my very first review. If I could give it 10 stars, I would. I love a clean WordPress installation. However, after using WordPress for some time, you get extra post types, most of which you can't even see unless you have a plugin or you know what you are doing. With this plugin I have been able to delete the extra post types that I'm not using, reducing the size of my WordPress installation.

Great plug-in!

By rubberneil on May 27, 2022

Custom Post Type Cleanup is a brilliant example of a plug-in created for one task - which it does superbly! Well done!

Still Works and Does a Nice Cleanup

By Fillip (innerfortune) on October 7, 2021

This plugin, even though it's over a year since its last update, still works as of this post date. I wanted to clean out all my custom post types. What the plugin found, in addition to the custom posts, were files that were left over from a previous theme I used years ago. This plugin cleaned all those files out.

1.3.2

  • Tested plugin to WP 6.5 on newer PHP versions.

1.3.0

  • Add batch size option to admin form.

1.2.0

  • Add ability to re-register unused custom post types.
Back to top