WordPress is powerful, but sometimes, things break. Instead of relying on plugins for every fix, here are some simple code-based solutions to common WordPress errors.
1. Fix “Allowed Memory Size Exhausted” Error
Issue: Your site crashes with an error saying, “Fatal error: Allowed memory size of XXXX bytes exhausted.”
Solution: Increase the PHP memory limit by adding this to wp-config.php:
define('WP_MEMORY_LIMIT', '256M');
If this doesn’t work, add this to your .htaccess file:
php_value memory_limit 256M
2. Fix Maximum Upload File Size Error
Issue: You’re unable to upload large media files due to a size limit.
Solution: Increase the limit by adding this to php.ini (if your host allows it):
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
If you don’t have access to php.ini, add this to .htaccess:
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
3. Fix “Too Many Redirects” Error
Issue: Your site keeps redirecting in a loop, causing the “ERR_TOO_MANY_REDIRECTS” error.
Solution: Disable forced HTTPS in wp-config.php:
define('FORCE_SSL_ADMIN', false);
Or, reset your site’s URL settings using functions.php:
update_option('siteurl', 'http://yourwebsite.com');
update_option('home', 'http://yourwebsite.com');
4. Fix “Pluggable.php File” Errors
Issue: You see an error mentioning pluggable.php, often after installing a new plugin.
Solution: This usually happens due to extra spaces in wp-config.php. Open the file and ensure it starts with <?php and has no blank spaces before or after the closing ?>.
5. Fix “Session Expired” or Login Issues
Issue: You keep getting logged out, or you can’t access the admin panel.
Solution: Update the cookie settings in wp-config.php:
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
If that doesn’t work, clear your browser cache or try logging in via wp-login.php instead of wp-admin.
6. Fix WordPress Not Sending Emails
Issue: WordPress contact forms or notifications aren’t being sent.
Solution: Set up SMTP using functions.php:
add_action('phpmailer_init', function($phpmailer) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.yourdomain.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'you@yourdomain.com';
$phpmailer->Password = 'yourpassword';
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = 587;
});
Need More Fixes?
These quick fixes should help you resolve common WordPress issues without relying on plugins. Keep your site running smoothly by staying on top of updates and regular maintenance.