Skip to content

Instantly share code, notes, and snippets.

@marklchaves
Last active February 11, 2026 13:31
Show Gist options
  • Select an option

  • Save marklchaves/71c038cfa2726ef098c693fb38febc77 to your computer and use it in GitHub Desktop.

Select an option

Save marklchaves/71c038cfa2726ef098c693fb38febc77 to your computer and use it in GitHub Desktop.
Code example that forces the CSS positioning for a specific popup on a specific page
<?php
/**
* Popup Maker Position Fix
*
* Adjusts the position of a specific popup after it opens.
*
* Useful when a theme or other pluging messes up the popup's default positioning.
*
* Usage: Add this code to your theme's functions.php or a custom plugin.
* - Update the popup ID (10349) to match your popup.
* - Change the CSS code below to what you need.
*
* This script only loads on the post/page slug: singapore-langkawi-twin-centre-escape
*/
/**
* Output the popup position fix script in the footer.
* Loads late (priority 500) to ensure it runs after other scripts.
*/
function pm_popup_position_fix_script() {
// Only load on the specific post(s) or page(s)
$allowed_slugs = [ 'singapore-langkawi-twin-centre-escape' ]; // Change this to your post/page slug(s)
$slug = get_post_field( 'post_name', get_queried_object_id() );
if ( ! in_array( $slug, $allowed_slugs ) ) return;
?>
<script>
jQuery(document).ready(function($) {
/**
* Function to fix popup position with a delay
*/
function fixPopupPosition() {
// Check if popup 10349 is the one that just opened
if ($('#pum-10349').hasClass('pum-active')) { // Change 10349 to your popup ID
console.log('Fixing popup 10349 position');
/**
* Add a slight delay before applying the positiong we want.
* That's so we get last dibs to make sure our position wins!
*/
setTimeout(function() {
// This is the part that fixes the conflict in the popup positioning.
// We force the position to the middle of the viewable area.
// NOTE: Change any of the CSS attributes to what you want.
$('#popmake-10349').css({ // Change 10349 to your popup ID
'margin': '0',
'top': '50%',
'left': '50%',
'transform': 'translate(-50%, -50%)',
'position': 'fixed'
});
}, 50); // 50ms delay; change as needed
}
}
/**
* Listen for the pumAfterOpen event.
* This fires after any Popup Maker popup finishes opening.
*/
$(document).on('pumAfterOpen', fixPopupPosition);
/**
* Listen for the pumBeforeReposition event.
* This fires before Popup Maker repositions the popup.
*/
$(document).on('pumBeforeReposition', fixPopupPosition);
});
</script>
<?php
}
add_action( 'wp_footer', 'pm_popup_position_fix_script', 500 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment