Redirects on popup plugin using WordPress
Jan 11th, 2020
If you are a freelancer or web design agency you probably have created or need to create a popup for your client's WordPress site. WordPress is something I am really not a fan of, but it makes up a large portion of small business and personal sites that you cannot really get away without using it from time to time. This is true when you are creating changes on a existing wp site created by someone else.
This time, a simple popup was needed, for which there is a zillion plugins for most of them which are paid plugins to access all the features.
For this task I used a popup plugin called `Popup Maker` which has quite a few nice features you can read up and is free.
Using the Popup Maker UI, I created a popup with an image that would show up on the site after 5 seconds. To create a redirect I to added the following script after the opening body tag using the Headers and Footers Plugin.
I ensured that the image had an id of popupImage so that I could an a click event listener on it. In addition, I needed to use setTimeout to ensure the function would only get called after 5 seconds, since that is when the popup with the id popupImage would appear on the screen.
Once a user clicked, they were than redirected to example.com/products.
Hope this example helps with your popup redirects and saves you some time and / or money so you don't need to purchase a popup plugin to access this functionality.