14.7. embed
, script
, and iframe
codes are not shown properly, or not shown at all
These are not shown because they are considered as security risks. Hence, WordPress removes these codes from the post content, although the plugin puts them into the post content. However, you can show them in several ways.
To show script
codes please see Showing scripts in post content guide. To show
iframe
codes, please see Showing iframes in post content. For showing embed
codes or for the case you do not want to use the built-in features, please keep reading.
If you want to show these HTML codes, you can use find-replace options of the plugin to replace
these codes with proper short codes that are defined in your site. For example, if you want to
retrieve embed
code for, say, YouTube, you can replace the iframe
code with a proper
embed short code by using a regular expression.
Below are some examples you can use.
14.7.1. Replacing all iframe HTML elements with [iframe]
short code
First, install iframe shortcode plugin. This plugin
will recognize our [iframe]
shortcode. Then, you can use below find-replace options (See:
Find and Replace Setting):
Regex: | Checked |
---|---|
Find: | <iframe\s([^>]*)><\/iframe> |
Replace: | [iframe $1] |
This replacement will turn the following code:
<iframe width="500" height="281" src="http://..." frameborder="0" allowfullscreen></iframe>
into the following code:
[iframe width="500" height="281" src="http://..." frameborder="0" allowfullscreen]
14.7.2. Replacing all iframe
HTML elements with
[embed]
shortcode (using src
attribute of the iframe
):
This example turns the iframe
into embed short code.
Regex: | Checked |
---|---|
Find: | <iframe.*?src=["']?([^"']+).*?><\/iframe> |
Replace: | [embed]$1[/embed] |
This replacement will turn the following code:
<iframe width="500" height="281" src="http://..." frameborder="0" allowfullscreen></iframe>
into the following code:
[embed]http://...[/embed]