How to Fix Fatal Error: Maximum Execution Time Exceeded in WordPress

The “Fatal Error: Maximum Execution Time Exceeded” in WordPress indicates that a script on your website has taken longer to execute than the allotted time limit, causing the process to be terminated. This can happen due to resource-intensive plugins, themes, or custom scripts. Here’s how to fix this error by increasing the maximum execution time:

Edit the .htaccess File

The .htaccess file, located in the root directory of your WordPress installation, can be used to increase the PHP maximum execution time. Here’s how:

  • Connect to Your Site via FTP or File Manager: Use an FTP client or the file manager provided by your hosting control panel.
  • Locate and Edit the .htaccess File: Find the .htaccess file in the root directory. If you can’t see it, make sure to enable the option to show hidden files in your FTP client or file manager.
  • Modify the .htaccess File: Add the following line at the bottom of the file:
  php_value max_execution_time 300

This sets the maximum execution time to 300 seconds (5 minutes). You can adjust the number as needed.

  • Save Changes: Upload the modified .htaccess file back to the server if you’re using FTP.

Edit the wp-config.php File

Another method is to increase the execution time by editing the wp-config.php file, which is also in the root directory of your WordPress installation.

  • Edit the wp-config.php File: Open the file and add the following line of code just before the line that says “That’s all, stop editing! Happy blogging”:
  set_time_limit(300);

This will also increase the maximum execution time to 300 seconds.

Edit the php.ini File

If you have access to the php.ini file on your server, you can directly increase the maximum execution time. This file is typically not accessible on shared hosting.

  • Locate and Edit the php.ini File: If you’re on a VPS or dedicated server, find the php.ini file (the location can vary). For shared hosting, you might be able to create a file named php.ini u korijenskom direktoriju vaše WordPress instalacije.
  • Modify the File: Add or modify the following line:
  max_execution_time = 300

Use a Plugin

Some WordPress plugins allow you to manage PHP settings, including the maximum execution time, directly from the WordPress admin dashboard. This can be a convenient option if you’re not comfortable editing files directly.

  • Install a Plugin: Look for a plugin that allows PHP configuration changes, such as WP Maximum Execution Time Exceeded or WP Config File Editor.
  • Adjust the Setting: Follow the plugin’s instructions to increase the maximum execution time.

Contact Your Hosting Provider

If you’re uncomfortable making these changes yourself, or if you’ve tried without success, contact your hosting provider. Some hosting environments restrict these changes, and your provider may need to adjust the execution time for you.

Zaključak

Increasing the maximum execution time can help resolve the “Fatal Error: Maximum Execution Time Exceeded” error in WordPress. However, it’s also important to investigate the underlying cause, such as a plugin or theme requiring excessive resources, to prevent future occurrences. Regularly maintaining your site, updating WordPress core, plugins, and themes, and using quality hosting can also help avoid such errors.