There are many ways to increase the PHP Time Limit for WordPress sites. I have compiled some of them so you can do several tests and choose the best one for you.
What Is The PHP Time Limit?
The PHP Time Limit is the amount of time that your site will spend on a single operation before timing out. When an operation reaches the time limit set, then it will return a fatal error that looks like this:
Fatal error: Maximum execution time of XX seconds exceeded
The default value for PHP time limit on most hosts for the PHP Time Limit is 30 seconds. You can increase this limit by following any of the the methods mentioned below.
Methods to increase the PHP Time Limit
There are some common and effective methods that we will share with you to increase the PHP time limit and avoid the fatal error that can occur when a script takes too long to execute.
1. Most Recommended: Just Contact Your Host
Increasing the PHP Time Limit is complex and the process that differs from hosts to hosts. So it is always better to get it done from someone who knows it well. So just get in touch with your hosting company and they will be happy to do it for you.
2. Increasing PHP Time Limit via PHP.ini file
Many small shared hosted servers do not allow users to access the PHP.ini file. If you are granted access, you can directly increase the PHP Time limit through this file. If you wish to extend the limit to 300 seconds, you can enter the following line of code or update if it exists already:
max_execution_time = 300;
3. Alternative to editing PHP.ini through wp-config.php
This is another alternative to the PHP.ini method. Simply add / edit the following line in the wp-config.php of your WordPress
set_time_limit(300);
4. Modifying the .htaccess file
Some of you might have the .htaccess file where you can simply add / edit this line of code to increase the time limit.
max_execution 300
5. Modifying the .htaccess file and wp-config.php
Add this to your .htaccess file
<IfModule mod_php5.c>
php_value post_max_size 16M
php_value upload_max_filesize 16M
php_value memory_limit 128M
php_value max_execution_time 300
php_value max_input_time 300
php_value session.gc_maxlifetime 900
</IfModule>
This to your wp-config.php
define('WP_MEMORY_LIMIT', '128M');
P.S: 300 in the above code samples mean 300 seconds. Feel free to change this to any appropriate number.