karl kliparchuk
karl kliparchuk

Reputation: 41

How to put a shortcode within an iframe?

I have a shortcode for a puzzle, but it is too wide for my wordpress text area. I would like to put the shortcode within an iframe that allows for scrolling or opens in a new window (so maybe no iframe needed). I cannot figure out how to do this. I have tried using do_shortcode( '[h5p id="4"]' ) and just '[h5p id="4"]' in the src= part of the iframe, but I keep getting a 404 error. The shortcode works on its own. Thanks for your help.

Upvotes: 1

Views: 730

Answers (1)

Mason
Mason

Reputation: 779

You don't have to put it in an iframe, wrap it around a class and style it:

<div class="puzzle-wrapper">
  <?php echo do_shortcode( '[h5p id="4"]' ); ?>
</div>

and in your style.css add something similar to this:

.puzzle-wrapper{
   min-width: 500px;
   max-width: 100%;
   overflow: scroll;
   height: 500px;
}

Upvotes: 1

Related Questions