Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7652

    George Brzozowski
    Participant

    Looking 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&#8217;
    }, 3000);
    </script>
    </body>
    </html>

    #7700

    Impressim
    Keymaster

    You 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

    #7702

    Anna J.
    Participant

    My 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&#8217;; // the redirect goes here

    },5000);
    ——————–
    @PHP
    header( “refresh:5;url=wherever.php” );

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

[snax_content]