---
title: Automatically Close Popup After 10 Seconds
description: "The following code sample is designed to close a popup (ID: #pum-123 ) after 10 seconds.  Copy, paste, and edit the following code in your child theme's `functions.php` file, or use the [My Custom Functions plugin](https://wordpress.org/plugins/my-custom-functions/) to install the code…"
url: "https://wppopupmaker.com/docs/special-popups/automatically-close-popup-after-10-seconds/"
updated: "2026-10-21"
category: Advanced / Special Popups
---

# Automatically Close Popup After 10 Seconds

The following code sample is designed to close a popup (ID: #pum-123 ) after 10 seconds. 

Copy, paste, and edit the following code in your child theme's `functions.php` file, or use the [My Custom Functions plugin](https://wordpress.org/plugins/my-custom-functions/) to install the code for you.

Replace [the popup ID number](https://wppopupmaker.com/docs/manage-features-or-options/find-the-popup-id/) in the code example with the value assigned to your popup. You can [find the ID](https://wppopupmaker.com/docs/manage-features-or-options/find-the-popup-id/) by going to  **Popup Maker**>** All Popups**>** CSS Classes**. The integer value is appended to the class name `popmake-`. 

```
<?php/** *  Note 1: Replace the placeholder popup ID used below ('#pum-123') with *  the value '#pum-{integer}'. From the WP Admin, go to Popup Maker *  > All Popups. Look at the CSS Classes column. Learn more at *  https://wppopupmaker.com/docs/manage-features-or-options/find-the-popup-id/ * *  Note 2: The units of time are milliseconds (ms). *  1 second = 1000 ms; 10 seconds = 10000 ms. * *  Add the following code to your theme (or child-theme) *  'functions.php' file starting with 'add_action()'. * -------------------------------------------------------------------------- */add_action( 'wp_footer', 'my_custom_popup_scripts', 500 );/** * Add a script to automatically close a popup after X seconds. * * @since 1.0.0 * * @return void */function my_custom_popup_scripts() { ?>    <script type="text/javascript">        (function ($, document, undefined) {            $('#pum-123') // Change 123 to your popup ID number.                .on('pumAfterOpen', function () {                    var $popup = $(this);                    setTimeout(function () {                        $popup.popmake('close');                    }, 10000); // 10 Seconds                });        }(jQuery, document))    </script><?php}
```

View the source on [GitHub](https://github.com/PopupMaker/Library/blob/master/Closing_Popups/automatically-close-popup.php).

If you need help adding PHP code to your site, check out our [Getting Started with Custom PHP](https://wppopupmaker.com/docs/getting-started-with-custom-code/getting-started-with-custom-php/) guide.
