I am trying to load a PHP function into a modal, containing a video. I'm currently using jquerymodal.com's plugin to achieve that. Here's the current .js code I'm using: https://jmp.sh/v/m3hLEwIXwaiRVCjONtEQ And the current CSS: https://jmp.sh/v/LSpOMPYauuumEEGzLrDW

Using PHP (basically something like <?php echo wp_show_posts_function(); ?>) to call any other text based content works just fine, only video functionality does not display right away (both oEmbed and third party video players). It displays only after closing and opening the modal multiple times, as shown in this short screen capture: https://vimeo.com/328915204

My function looks like this, echoing a videoplayer inside an iframe:

  function wp_show_posts_videolink() {
    global $post;
    $videol = get_field('videolink');

    if ( '' != $videol ) {
      $allowed_tags = '<script>,<iframe>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<img>,<video>,<audio>, <div>'; /*** MODIFY THIS. Add the allowed HTML tags separated by a comma.***/
      $text = strip_tags($text, $allowed_tags);
      echo '<div style="padding-top: 50.07%; position: relative; overflow: hidden;"><iframe allowfullscreen="" scrolling="no" style="position: absolute; height: 100%; width: 100%; left: 0px; top: 0px;" src="https://onelineplayer.com/player.html?autoplay=false&loop=true&autopause=false&muted=false&url=https%3A%2F%2Fvimeo.com%2F226137389&poster=&time=true&progressBar=true&playButton=true&overlay=true&muteButton=true&fullscreenButton=true&style=light&logo=true&quality=720p" frameborder="0"></iframe></div>';


    return apply_filters('the_excerpt', $text, $standort);

And my content calling on that function looks like this:

<div id="videomodal" class="modal">
    <?php echo wp_show_posts_videolink(); ?>
        <p>Thanks for clicking.</p>
        <a href="#" rel="modal:close">Close</a>

Somewhere between display:none and display:block the jQuery modal gets stuck in displaying the video. Again, all other php functions without video (just plain text or Links) work immediately, only videos display after multiple tries of opening and closing the modal window, as shown in the linked above video.

How can I get the modal to open the video right away?

  • Any error in developer console? Where does $videol come from?
    – moped
    Apr 8, 2019 at 6:12
  • Hi @moped, there are no errors through the developer console. Everything concerning styling and javascript gets loaded. $videol is a custom field I want to introduce later on and is just for testing purposes (its not in use yet). Right now I just want to get a simple video working (the iframe inside the function) via PHP inside the modal. Using just the divs and iframe without any function the modal displays it correctly, using php to echo the function from somewhere else, containing the div and iframe, does not. Apr 8, 2019 at 10:19


This site is temporarily in read-only mode and not accepting new answers.

Browse other questions tagged .