Are you looking to increase PHP Time Limit in WordPress?
During WordPress-ing, you may encounter ‘Maximum execution time of 30 seconds exceeded’ or ‘Maximum execution time of 60 seconds exceeded’.
It means that the task executed is taking more time than the PHP has assigned.
In this short tutorial article, I will show you how you can increase the PHP Time Limit.
What is PHP Time Limit?
As WordPress built on PHP, there is a lot of PHP execution going on in the background. To keep everything in order, WordPress developers add the PHP Time Limit.
PHP Time Limit caps the time that could be spent on one task to execute. If that script or code does not load under that time, the PHP will show the time out.
If the operation is critical to load the page, it will return the fatal error showing that the PHP has run out of the time.
You can quickly increase that time. However, the PHP operation should not take more than 3-4 seconds.
Increase PHP Time Limit by using wp-config.php
You have to edit the wp-config.php file from the WordPress core folder.
Go to your cPanel and open the File Manager. In the root folder, you will find the wp-config.php.
Edit the file and add the following line of code into it.
Hit the save button to save changes. Come back to your site to check if it is still showing the error.
Increase PHP Time Limit using .htaccess
If you do not want to make changes in the config.php file, you can increase the PHP time limit with the .htaccess file.
You can edit the .htaccess file from the WordPress dashboard or backend file manager.
Whichever way you choose, you have to paste the following code into the .htaccess file.
Save the changes, and check if the error is gone. Most of the time, this will solve the error of the time limit.
PHP maximum execution time limit in php.ini
Making edits in the php.ini file affects all the php scripts of the system. For content management systems like WordPress, Magento and Drupal, it is the best solution as you don’t have to make changes in each folder.
Open php.ini file using your favorite text editor.
$ sudo vi /etc/php/7.2/apache2/php.ini
Look for max_execution_time directive.
; Maximum execution time of each script, in seconds
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 30
Set the value for max_execution_time in seconds.
max_execution_time = 300
Restart your web server.
$ sudo systemctl restart apache2
Contact the Host
Sometimes, the hosting provider does not let the users increase the PHP time limit.
If you cannot do it by editing the .htaccess file or wp-config.php file, you should contact your host.
Just connect with your hosting company. A quality hosting provider will do it gladly.
Getting error due to the low PHP time limit could be irritating.
In this quick post, I mentioned the easiest methods to increase the WordPress site’s PHP time limit.
I hope it helps you, and if there are any questions and doubts, please leave them in the comment box.