Opening an external url in a pop-up window for a specific page


Note : the following code snippet requires advanced WordPress developer skills. There's no guarantee that this snippet works as is with the latest version of our themes, and with the latest version of WordPress. That's why you need to always test any code snippets in a staging environment before implementing it in a production site.


To do that, you need :
1) The linked page ID (easy to find in the url when editing the page in admin)
2) the external page URL

Copy and paste the code below in your functions.php

 

You can add a timer if you want the pop up to open after a delay :

 


Related Snippets you may also like


5 thoughts on “Opening an external url in a pop-up window for a specific page

  • Rain

    Hi. how can I add more page ID and external URLs to functions.php? Example: 2 more links to add in my website. Thanks!

  • Richard Andrews

    I tried inserting this code in my functions.php of my child theme, but, i am not sure where to put the page ID and how the redirect link should be formatted. Can you give an example what the completed code should look like.

    • Nicolas Post author

      Hi Richard,

      Here’s an example where the page id is 2 and external url is wordpress.org.

      Hope this helps!

Comments are closed.