You can define the maximum execution time for WordPress by adding the following line of code to the wp-config.php file:
set_time_limit(300);
Replace 300
with the desired number of seconds. This sets the maximum time in seconds a script is allowed to run before it is terminated by the server. The default value is 30 seconds. If you need to run longer scripts, you may need to increase this value.