WP PHP maximum execution time or PHP time limit is the amount of time in seconds that a website will spend on a single operation before timing out. This time is useful to avoid any potential server lockup. The default PHP time limit for WordPress is 30 seconds. When a certain operation reaches this execution time limit, the system will return the “Maximum execution time of X seconds exceeded” fatal error. 30 seconds may not be enough to install a complete demo for a theme or big plugin, thus it will be prudent to increase it so that your website can successfully complete the operation.
How to increase WP max execution time
The recommended WordPress maximum execution time is 300 seconds.
a. wp-config.php
- Locate the wp-config.php file in the root directory of your WordPress installation. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the wp-config.php file under the public_html folder, right click on it and select the “Edit” option.
- Locate the line that has; set_time_limit(30);
- Change the max execution time from 30 to 300.
- Save the wp-config.php file then refresh your website.
b. functions.php
- Open your theme files and locate the functions.php file. You can contact your theme developer for assistance if required.
- Locate the line that has; @ini_set(‘max_execution_time’, ’30’);. If you can’t find that line, you can simply add it.
- Change the post max size from 30 to 300.
- Save the functions.php file then refresh your website.
c. php.ini
- Locate the php.ini file. If you cannot find it, then simply create your own php.ini file and place it in the root directory of your WordPress installation. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the .php.ini file under the public_html folder, right click on it and select the “Edit” option.
- Locate the line that has; max_execution_time = 30. If you created your own php.ini file, ensure you add the line.
- Change the post max size from 30 to 300.
- Save the php.ini file then refresh your website.
Some shared hosting providers restrict you from accessing the php.ini file. This method is only applicable in case you have direct access to your php.ini file or if you are running your WordPress on a local host.
d. .htaccess
- Locate the .htaccess file in the root directory of your WordPress installation. If you can’t find it, then it might be hidden. Make sure to check your hidden files when locating it. Using cPanel or FTP/SFTP, go to File Manager > public_html.
- Locate the .htaccess file under the public_html folder, right click on it and select the “Edit” option.
- Locate the line that has; php_value max_execution_time 30. If you can’t find that line, you can simply add it before the # END WordPress line.
- Change the post max size from 30 to 300.
- Save the .htaccess file then refresh your website.