How to fix : Allowed Memory Size Exhausted Error

Allowed Memory Exhausted Error
A memory exhausted error causes either a white screen of death or the following error :

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/username/public_html/site1/wp-includes/plugin.php on line xxx

Cause

The main cause is when a WordPress plugin or a script exhausts the default memory limit.

Solution

You need to increase your PHP memory limit. Even though we have mentioned all the steps of increasing the memory limit in the first point, I am still writing it here.

To increase the limit, open your wp-config.php file and add the following line of code within the main PHP tags.

define('WP_MEMORY_LIMIT', '64M');

The above code increases your memory limit to 64M.

Replace your theme with the default theme and disable all plugins

How to fix Internal Server Error in wordpress

Internal Server Error

This is another common problem that almost every WordPress website encounters at least once. There are several potential causes.

Causes:

  • Exhausted PHP memory limit
  • Corrupted plugin functions
  • Corrupted theme functions
  • Corrupted .htaccess

Solution #1. Increase the memory limit

Follow the same steps to increase the memory limit as mentioned in the previous step.

Solution #2. Edit .htaccess file

Since the problem is usually caused by a corrupted .htaccess file, you would need to edit your .htaccess file. Open your .htaccess file from the FTP or file manager and rename it with .htaccess old. Refresh your website and see if the problem persists. If this fixes the problem, click on settings > permalinks and hit save changes to reset .htaccess.

Solution #3. Deactivate all the plugins

If changing your .htaccess file did not have any impact on the problem, you might want to check your plugins. Deactivate all your plugins by clicking on plugins ? installed plugins. Choose “deactivate” from the “bulk action” drop down and hit apply. It will automatically deactivate all your plugins. Now go to your website, refresh it and check if the error is gone. If so, activate your plugins one by one and see which plugin has caused the problem.

Solution #4. Replace wp-admin and wp-includes folders

If nothing worked, try replacing your wp-includes and wp-admin folders with fresh copies from a WordPress install. Save them and upload. Refresh the browser and see if the problem is resolved.

How to fix White Screen of Death error

White Screen of Death

This error usually causes a plain white screen of death with no error message, making it more frustrating for you since you have no idea what to seek and what to fix.

Causes:

  • Often caused by an exhausted memory limit
  • Poorly coded theme or plugin

Solution #1: Increase the memory limit

Since exhausted memory limit is one popular reason of this error, it is recommended to increase the memory limit. To increase the limit, open your wp-config.php file and add the following line of code within the main PHP tags.

define('WP_MEMORY_LIMIT', '64M');

The above code increases your memory limit to 64M.

Solution #2. Replace your theme with the default theme and disable all plugins

If the problem still persists, disable all your plugins and replace your currently active theme with the default WordPress theme and check if it still shows a white screen of death. If the problem is resolved, either your theme or one of your plugins is causing a white screen. Activate one plugin at a time while keeping an eye on the website. If this resolves the problem, check your theme’s functions.php and remove any extra spaces at the bottom of the file.

Exclude category posts from displaying on Blog page

Exclude category posts from displaying on WordPress

This tutorial will show you how to exclude category posts from displaying on Blog page in WordPress.
Exclude category posts

  1. Log into your WordPress dashboard, and navigate to Appearance > Editor:
  2. Choose themeXYZ, where XYZ is your actual theme number in Select theme to edit drop down:
  3. Find custom-function.php file and open to edit it.
  4. You will need to get your category ID before editing this file. You should navigate to Posts > Categories:
  5. Hover over the category name (that you want to exclude from blog page) to see its ID:
  6. Add this code to the very end of the file before closing php tag ?> and replace 6 with your category ID:
    1
    2
    3
    4
    5
    6
    function exclude_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( 'cat', '-6' );
    }
    }
    add_action( 'pre_get_posts', 'exclude_category' );
  7. Click Update file button to save changes.
  8. If you want to exclude 2 or more categories, you should separate them with comma in the code, example:
    1
    $query->set( 'cat', '-6,-7' );
  9. Refresh your Blog page, now it doesn’t display posts from the category that was excluded in the file.

PCLZIP_ERR_MISSING_FILE (-4) : Missing archive file ‘/{plugin..}.tmp’ : error in wordpress

How to fix PCLZIP_ERR_MISSING_FILE (-4) Missing file ‘/{somefile.tmp}’ error when updating plugin in WordPress

This solution is based on this WordPress.org thread.

PROBLEM

When you try to update WordPress or install plugins, the downloader / installer page pops up, the compressed file is downloaded to your server, but installation fails because of this error:

PCLZIP_ERR_MISSING_FILE (-4) : Missing archive file ‘C:\Windows\TEMP/{whatever you were installing}.tmp’

SOLUTION

You need to access the files on your server via FTP. If you haven’t done this before, there are tutorials out there. Short version: find the FTP access details for your server, and grab FileZilla FTP Client. Or if your hosting provides a File Manager utility, use that.

On your server, navigate to the /wp-content folder. Create a new folder inside it called TEMP.

Download /wp-config.php from your server to your computer. Open it up in a text editor, and beneath

if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');

add the line

define('WP_TEMP_DIR', ABSPATH . 'wp-content/TEMP');

then save wp-config.php. Upload it to your server again.

Try updating WordPress or installing a plugin. It should work now.

The other solution is not to use Windows hosting!