How to Make a WordPress Page Load with a Popup Pre-Opened Using a Special URL

Popup Maker is a popular and useful WordPress plugin for creating website popups. The popups can open automatically after a preset time or through a click event on the page or in your menu.

But one feature I haven’t found natively in Popup Maker is the ability to tell the page to automatically open the popup when you visit a variation of its URL. In other words, how to make your page load with a popup already opened. For example, let’s say you have this page that has some popups which are not shown by default:

But, you’d like the page to load with a popup already opened when you visit this URL:

This could be very useful for social sharing, forwarding links, and so on.

This article describes how to do that!

The Popup Maker Code

I’m going to jump straight to the answer and give you the code to do it, then explain how to use it. Here it is:

jQuery(document).ready(function() {
  var id = window.location.hash;
  switch (id) {
    case "#chocolate":; break;
    case "#vanilla":; break;
    case "#strawberry":; break;
    case "#pistachio":; break;
    case "#coffee":; break;
    case "#mint":; break;
    case "#cherry":; break;

Basically, we grab the hash from the URL, then call the global function to open the appropriate popup, based on the popup ID.

So, with the code above, if I visted:

Then, the page should open with popup with ID 1135 opened!

How to Use This Code

Insert a hash for each of the popups you want to open using this method, then substitute in the correct Popup Maker IDs in the code above. Pretty straightforward!

This code can go into your child theme’s JS file, or you can “cheat” and just put it in a Gutenberg HTML block wrapped in <script> tags.

Let me know if it works for you! – Brian


Please Leave a Question or Comment

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments