- This topic has 2 replies, 3 voices, and was last updated 2 years, 9 months ago by Anna J..
-
AuthorPosts
-
January 19, 2022 at 8:39 am #7652
George BrzozowskiParticipantLooking for some PHP snippet for wordpress plugin (RankMath) that redirect users after spending 5 seconds on the website.
Basically, RankMath offers the features of link redirect. When user clicks on the link they get auto redicredted immediately. I don’t want to it to happen. I want when users clicks on the redirect link, after that they comes to the website and stay there for ~5m then it auto redirects them to the destination page.
Any help will be highly appreciated.I found this script but i need PHP snippet
<html>
<body>
<p>You will be redirected in 3 seconds</p>
<script>
var timer = setTimeout(function() {
window.location=’http://example.com’
}, 3000);
</script>
</body>
</html>- This topic was modified 2 years, 9 months ago by George Brzozowski.
- This topic was modified 2 years, 9 months ago by Impressim.
February 9, 2022 at 2:30 pm #7700
ImpressimKeymasterYou don’t need a PHP snippet. Just copy-paste the SCRIPT you provided and it will redirect if you include it in a wordpress post or page. This is assuming it doesn’t get polluted by wordpress’s tendency to surround lines with P tags. You can always create a shortcode for redirecting. This is such a common task, just search around. For example you can use wordpress.org/plugins/shortcode-redirect
February 9, 2022 at 2:42 pm #7702
Anna J.ParticipantMy recommendation is to contact RankMath developers to ask about their plugin hooks. If there is any available hook for redirection then use it with the PHP code. Otherwise edit the RankMath plugin where the redirection code is and replace that code with the redirection code offered by wordpress.org/plugins/shortcode-redirect. You can also check by editing Shortcode Redirect plugin what tip or strategy they are using to redirect after few seconds. It won’t be more than 2-3 lines of code.
——–
@Javascript
setTimeout(function () {
window.location.href= ‘http://www.google.com’; // the redirect goes here},5000);
——————–
@PHP
header( “refresh:5;url=wherever.php” ); -
AuthorPosts
You must be logged in to reply to this topic.