How to Fix WordPress Issue: Cannot Add New Page or Post (Corrupted Database)

If you’re facing issues adding new posts or pages in WordPress, and you’ve ruled out plugin and theme conflicts, it might be a database problem. Follow these steps to troubleshoot and resolve the issue:

Step 1: Identify and Confirm the Issue

  1. Disable Plugins and Themes: Start by deactivating all plugins and switching to the default WordPress theme (e.g., Twenty Twenty-One). Confirm if the problem persists.
  2. Check for Core Updates: Ensure there’s no ongoing core update by verifying the absence of ‘core_updater.lock’ in ‘wp_options’ table.
  3. Investigate WordPress Logs: Enable WP_DEBUG in your WordPress installation and check the error logs for any issues. Look for entries indicating a database error, especially involving a duplicate entry for the ‘PRIMARY’ key.

Step 2: Analyze Database for Duplicates

  1. Examine wp_posts Table: Inspect the ‘wp_posts’ table for entries with ‘ID=0.’ If found, attempt to delete these entries. Note that deleting might not entirely resolve the issue.

Step 3: Resolve Duplicate Entry Issue

  1. Backup Database: Before making changes, it’s crucial to back up your database. Use a tool like phpMyAdmin or a plugin for this task.
  2. Identify and Remove Duplicate Entries: Run a query to find and remove duplicate entries in the ‘wp_posts’ table. Execute a query similar to:
DELETE FROM wp_posts WHERE ID = 0;

Step 4: Check and Repair Database

  1. Database Repair: WordPress provides a built-in tool for database repair. Add the following line to your wp-config.php file:
define('WP_ALLOW_REPAIR', true); 

Access ‘yoursite.com/wp-admin/maint/repair.php’ in your browser and follow the on-screen instructions.

Step 5: Investigate Customized Plugin

  1. Plugin Compatibility: Verify if a customized plugin caused the initial issue. Check for updates or contact the plugin developer for assistance.
  2. Recreate Database Connection: Create a clean WordPress 5.7 install, linked to a copy of the database from the previous installation. Ensure no plugins are active. If the issue persists, the problem might be in the database itself.

Step 6: Seek Professional Assistance

  1. Database Expert: If the problem persists, consider reaching out to a database expert or a WordPress developer. They can provide a more in-depth analysis and solution.

By following these steps, you should be able to identify and resolve the issue causing the inability to add new posts or pages in WordPress.

Was this helpful?

Thanks for your feedback!

Leave a Reply

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