PopUp on a specific page and all single & archive post pages

I have a popup I want to appear on the following:
1. all singe posts
2. all post archives
3. my blog page (domain.com/blog/), which is an actual WordPress Page, not the traditional blog.

I set the options for the popup as:
- On a specific URL: domain.com/blog/
- For Specific post types: posts - singular and archive are checked

With the settings like this the popup doesn't show on any page.

The settings work only as an "and" option between them. There's no way to set up these as an "or" option?

The only solution I've found is to create two of the same popup and add one to only show on the blog page. Is that correct?

Then, if they click the close button they'll still be shown the other popup, until they click the other popup's close button.

  • Philipp Stracker

    Hi @fox,

    thanks for the input. I am afraid that currently ALL conditions have to be true in order for the PopUp to show.

    Two options:

    1.) If your archive/post have some distinct URL prefix like "blog/" then you can use the "Advanced URL" rule with this lines:

    http://yoursite\.com/$
    http://yoursite\.com/blog/
    http://yoursite\.com/2014/

    Note: The "$" in the first line and that we use "\." instead of "." are important - those are 3 regular expressions that you can customize to meet your URL structure. E.g. The second line will match all pages on your site which have an URL starting with "yoursite.com/blog/"

    2.) There is a very flexible solution that requires you to write your own PHP function using the hook "popup-apply-rules".
    - In your PopUp only keep the PostType rule, remove the URL rule
    - Then add this code to your themes "function.php" file
    - Change "123" to the PopUp ID (you see the ID in the URL when you edit the PopUp):

    add_filter('popup-apply-rules', 'my_popup_condition', 999, 2);
    function my_popup_condition($def_value, $popup) {
      if ( $popup->id == 123 && is_front_page() ) {
        // This will force PopUp 123 to be displayed on front page,
        // overriding any other condition that was defined.
        return true;
      } else {
        // If the PopUp is not 123 or the page is not the front page
        // then use the default condition result.
        return $def_value;
      }
    }

    Note: This will work with the loading method "Page Footer". In case you have trouble with getting this to work with any of the other loading methods then let us know and I will review the code and give you a working example.

    Thanks, Philipp :wink:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.