Using WordPress ‘iframe_footer()’ PHP function

The iframe_footer() WordPress PHP function generates a generic iframe footer for use with Thickbox.

Usage

iframe_footer();

Parameters

  • None

More information

See WordPress Developer Resources: iframe_footer

Examples

Add the iframe_footer() function at the end of your PHP file to display a Thickbox iframe footer:

// Your PHP code

// Add iframe footer for Thickbox
iframe_footer();

Create a custom Thickbox popup

Create a custom Thickbox popup with content and use iframe_footer() to add the iframe footer to it:

// Enqueue Thickbox scripts and styles
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');

// Add custom Thickbox content
echo '<div id="my-thickbox-content" style="display:none;">';
echo '<h2>My Thickbox Popup</h2>';
echo '<p>This is the content of my custom Thickbox popup.</p>';
echo '</div>';

// Add the Thickbox link
echo '<a href="#TB_inline?width=600&height=550&inlineId=my-thickbox-content" class="thickbox">Open Popup</a>';

// Add iframe footer for Thickbox
iframe_footer();

Display a YouTube video in a Thickbox popup

Display a YouTube video within a Thickbox popup using the iframe_footer() function:

// Enqueue Thickbox scripts and styles
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');

// Add the Thickbox link
echo '<a href="https://www.youtube.com/embed/VIDEO_ID?autoplay=1&rel=0&TB_iframe=true&width=640&height=360" class="thickbox">Watch Video</a>';

// Add iframe footer for Thickbox
iframe_footer();

Display an image gallery within a Thickbox popup using the iframe_footer() function:

// Enqueue Thickbox scripts and styles
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');

// Add the image gallery
echo '<div id="my-image-gallery" style="display:none;">';
echo '<img src="image1.jpg" alt="Image 1">';
echo '<img src="image2.jpg" alt="Image 2">';
echo '<img src="image3.jpg" alt="Image 3">';
echo '</div>';

// Add the Thickbox link
echo '<a href="#TB_inline?width=800&height=600&inlineId=my-image-gallery" class="thickbox">Open Gallery</a>';

// Add iframe footer for Thickbox
iframe_footer();

Display an iframe in a Thickbox popup

Display an iframe within a Thickbox popup using the iframe_footer() function:

// Enqueue Thickbox scripts and styles
wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');

// Add the iframe content
echo '<div id="my-iframe-content" style="display:none;">';
echo '<iframe src="https://example.com" width="100%" height="100%"></iframe>';
echo '</div>';

// Add the Thickbox link
echo '<a href="#TB_inline?width=800&height=600&inlineId=my-iframe-content" class="thickbox">Open Iframe</a>';

// Add iframe footer for Thickbox
iframe_footer();