• Resolved Leah

    (@edikitt)


    Not sure if there might a better way to achieve this, but I have two different types of pages that I want to show two different popups on. I have a custom field key that I’m using to reference these two different types of pages.

    Is there a way that I could show one popup if that custom field key is equal to 1, and the other popup if the key is equal to 2?

    I know how to create the conditional that checks for the presence of that key, but I’m not sure how to then show or hide the specific popup.

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Leah

    (@edikitt)

    Alternatively, is there a way to set priority for popups? Or perhaps make them conditional on the presence of other popups?

    So, for example, let’s say I have P1 set to display on all pages and P2 set to display on certain pages. Is there a way that I could tell P1 not to display on pages where P2 is active?

    Thread Starter Leah

    (@edikitt)

    Figured out a workable solution.

    So my problem was that I have two popups in the same location, but I didn’t want both to appear at the same time. As of right now, the only way for me to achieve this was to select every individual page in the display options that I want each popup to appear on. Not ideal.

    Instead, I have the display rules for Popup 1 set so that they display on any page other than the ones I’ve set. I have Popup 2 set to display on all pages. Then I’m just using jQuery to remove Popup 2 on any page where Popup 1 is active.

    This still isn’t all that elegant of a solution since I still need to set all of the individual pages for one of the popups, but it’s certainly better than having to assign every single page on my site to one or the other popup.

    JS for anyone who’s interested:

    jQuery(function($){

    if ( $(‘POPUP_1_ID’).css(‘display’) == ‘block’ ) {
    $(‘POPUP_2_ID’).remove();
    }

    });

    Thread Starter Leah

    (@edikitt)

    Sorry for the repeated posts in this thread, but I found a better way to do this and thought I would share for anyone else who might happen across this problem.

    I just created a custom page template that is an exact copy of page.php. The only difference is the name of the template, which you assign at the top of the file (after the opening <?php tag) like so:

    /*
     * Template Name: My New Template
     * Description: Optional description
     */

    (Note: You can save this file in your (preferably child) theme root directory or a sub-directory of the root.)

    Then I just assigned that template to all of the pages that I wanted to show my specific popup on. You can change page templates very quickly in WordPress by bulk editing any pages you select and changing your selection from the Template dropdown.

    From there I simply set the Popup Display Rules to show if the page template is equal to my new custom template, which is assigned to all of the pages that I wanted my popup to show up on.

    Much more elegant than manually selecting each individual page!

    Plugin Author Damian

    (@timersys)

    Thanks for sharing!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display popup based on custom field?’ is closed to new replies.