How to Fix a Site Crash Caused by a WPCode Snippet
Content
One of the most common issues users face with the WPCode plugin is a site crash triggered by a faulty PHP snippet. This can be a stressful experience, especially if the error prevents you from accessing your WordPress dashboard to deactivate the problematic code. This guide will explain why this happens and walk you through the most effective solutions to get your site back online.
Why Does a Deleted Snippet Still Crash My Site?
Based on community reports, a recurring theme is confusion when a site remains broken even after a user has deleted a problematic snippet directly from the database. The reason for this is related to how the WPCode plugin optimizes performance.
WPCode preloads active snippets into a cache to make them execute faster. When you delete a snippet from the wp_posts table in the database, you remove its configuration, but the cached, preloaded version of the code may still be present. This means the faulty code can continue to run and cause errors until the cache is cleared. The intended and safest method to handle this is not through direct database edits, but by using the built-in safe mode tool.
Solution 1: Use WPCode Safe Mode (Recommended)
The primary and most reliable method to regain access to your admin dashboard is WPCode's Safe Mode. This feature temporarily prevents any snippets from executing, allowing you to safely log in and manage your snippets.
- Ensure the WPCode plugin is active. If you renamed or deactivated it via FTP, you must first reverse that change so the plugin is active again, even if the site appears broken.
- Construct a special URL to access your WordPress admin panel. Simply add
?wpcode-safe-mode=1to the end of your admin URL. It will look like this:https://yourwebsite.com/wp-admin/?wpcode-safe-mode=1 - Navigate to this URL in your browser. You should now be able to log in without the snippet causing errors.
- Once inside the dashboard, go to Code Snippets » All Snippets.
- Find the snippet that caused the issue and deactivate it by toggling its switch.
- Important: If you had already deleted the snippet from the database, you may need to activate and then deactivate a different snippet. This action forces the snippet cache to reset and clear out any remnants of the deleted code.
After completing these steps, you can exit safe mode by reloading your admin dashboard without the safe mode parameter. Your site should now be functioning normally.
Solution 2: Reset the Snippet Cache via Database (Advanced)
If safe mode is inaccessible for any reason, a more advanced solution involves directly querying the database to reset the snippet cache. This should be done with caution and preferably after a full backup.
- Access your database via a tool like phpMyAdmin, provided by your hosting provider.
- Locate your site's WordPress database and find the
wp_optionstable (the prefix may be different, e.g.,myprefix_options). - Find and delete the record where the
option_nameiswpcode_snippetsorwpcode_snippets_updated(the name may vary slightly).
Deleting this option will clear the preloaded snippet cache. Upon the next page load, WordPress will rebuild this cache from the snippets currently active in the database. If the faulty snippet has already been deleted, the cache will be rebuilt without it, resolving the error.
Conclusion and Best Practices
Dealing with a white screen of death or a 503 error can be alarming, but the solution is often straightforward. The WPCode team designed the safe mode specifically for this scenario. To avoid future issues, always test new snippets on a staging site first and use the safe mode to deactivate problematic code instead of making direct changes to the database.
Related Support Threads Support
-
Deactivated All Snippetshttps://wordpress.org/support/topic/deactivated-all-snippets/
-
There has been a critical error on this website.https://wordpress.org/support/topic/there-has-been-a-critical-error-on-this-website-280/
-
Snippet deactivated after WP directory changehttps://wordpress.org/support/topic/snippet-deactivated-after-wp-directory-change/
-
All Code Snippets stopped workinghttps://wordpress.org/support/topic/all-code-snippets-stopped-working/
-
Where are the snippet saved in the database?https://wordpress.org/support/topic/where-are-the-snippet-saved-in-the-database/
-
Old scripts not showing i pluginhttps://wordpress.org/support/topic/old-scripts-not-showing-i-plugin/
-
How to remove snippet file manually from cPanelhttps://wordpress.org/support/topic/how-to-remove-snippet-file-manually-from-cpanel/
-
Where does WPCode store my snippets?https://wordpress.org/support/topic/where-does-wpcode-store-my-snippets/
-
Migrating from code-snippethttps://wordpress.org/support/topic/migrating-from-code-snippet/
-
Header Snippet not found in databasehttps://wordpress.org/support/topic/header-snippet-not-found-in-database/
-
php snippet is being “amended” when I disable and then enable the snippethttps://wordpress.org/support/topic/php-snippet-is-being-amended-when-i-disable-and-then-enable-the-snippet/
-
Critical Error – deleted code in PHP but can’t reload pluginhttps://wordpress.org/support/topic/critical-error-deleted-code-in-php-but-cant-reload-plugin/
-
Activate Code Snippets plugin crashes websitehttps://wordpress.org/support/topic/activate-code-snippets-plugin-crashes-website/
-
Delete faulty Code Snippets from the pluginhttps://wordpress.org/support/topic/delete-faulty-code-snippets-from-the-plugin/
-
Not Able to remove snippethttps://wordpress.org/support/topic/not-able-to-remove-snippet/
-
Where is the snippet?https://wordpress.org/support/topic/where-is-the-snippet/
-
Retrieve/Delete snippets while plugin deactivatedhttps://wordpress.org/support/topic/retrieve-delete-snippets-while-plugin-deactivated/
-
Fatal error after messing up a snippet, even after deleting from databasehttps://wordpress.org/support/topic/fatal-error-after-messing-up-a-snippet-even-after-deleting-from-database/
-
Plugin Crashed due to die functionhttps://wordpress.org/support/topic/plugin-crashed-due-to-die-function/
-
Site Brokenhttps://wordpress.org/support/topic/site-broken-46/
-
All snippets stopped workinghttps://wordpress.org/support/topic/all-snippets-stopped-working/
-
How can I cleanup faulty PHPsnippets injected via the pluginhttps://wordpress.org/support/topic/how-can-i-cleanup-faulty-phpsnippets-injected-via-the-plugin/
-
A snippet crashes my sitehttps://wordpress.org/support/topic/a-snippet-crashes-my-site/
-
WordPress is broken and I can’t delete the snippethttps://wordpress.org/support/topic/wordpress-is-broken-and-i-cant-delete-the-snippet/
-
Bad snippet error persists after deletion?https://wordpress.org/support/topic/bad-snippet-error-persists-after-deletion/
-
Redirect loop failhttps://wordpress.org/support/topic/redirect-loop-fail/
-
Snippets are not workinghttps://wordpress.org/support/topic/snippets-are-not-working/
-
Snippets with errors notice in admin barhttps://wordpress.org/support/topic/snippets-with-errors-notice-in-admin-bar/