How to refresh wordpress plugin in a period of time that i selected?

*爱你&永不变心* 提交于 2019-12-11 18:46:56

问题


I wrote a plugin for wordpress and i want it to refresh in every 3 hours i tried header("refresh:10800;url=example.php") but i couldn't get any result.

Thanks for your helps.


回答1:


you could try with javascript:

setTimeout(function(){ window.location = 'example.com' },10800)

let us know how you get on in 3 1/2 hours or so...




回答2:


You've gotten confused between the PHP header() function and the HTML HEAD section.

The PHP header( 'Location: newpage.htm' ); performs an instantaneous redirect to newpage.htm (and should be directly followed by a call to die()). There is no potential to delay that redirection.

Within the HTML <head> ... </head> section, you can use a META Tag to perform a delayed refresh or redirection:

<!-- Refresh the Current Page every 10 minutes (600 seconds) //-->
<meta http-equiv="refresh" content="600">

<!-- Redirect to Another Page with a Delay of 10 minutes (600 seconds) //-->
<meta http-equiv="refresh" content="600;url=http://anotherserver.com/">


来源:https://stackoverflow.com/questions/5448856/how-to-refresh-wordpress-plugin-in-a-period-of-time-that-i-selected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!