Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Embed Shortcode"

m (added language xref link to Japanese Codex)
(Added note on how to use this shortcode is special circumstances)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
}}
 
}}
   
The '''Embed''' feature allows you to wrap [[Embeds|embedded items]] using a simple [[Shortcode]] to set of a maximum (but not fixed) width and height. This was added as of WordPress [[Version 3.6|3.6]] and is used like this:
+
The '''Embed''' feature allows you to wrap [[Embeds|embedded items]] using a simple [[Shortcode]] to set of a maximum (but not fixed) width and height. This was added as of WordPress [[Version 2.9|2.9]] and is used like this:
   
 
[embed]...[/embed]
 
[embed]...[/embed]
Line 10: Line 10:
 
== Usage ==
 
== Usage ==
   
I have an embedded item, and I want to set max dimentions:
+
I have an embedded item, and I want to set max dimensions:
   
 
[embed width="123" height="456"]...[/embed]
 
[embed width="123" height="456"]...[/embed]
  +
  +
'''Note:''' This shortcode isn't enabled until <tt>[[Plugin_API/Filter_Reference/the_content | 'the_content']]</tt> filter has been processed at least once. If you need to run this shortcode before or without [[The_Loop|The Loop]] and aren't using <tt>[[Function_Reference/the_content | the_content()]]</tt> you'll need to call the following method with the content which contains the [embed] shortcode:
  +
  +
$GLOBALS['wp_embed']->run_shortcode( 'Content with [embed] shortcode' );
   
 
== Options ==
 
== Options ==

Latest revision as of 19:13, 10 January 2019

The Embed feature allows you to wrap embedded items using a simple Shortcode to set of a maximum (but not fixed) width and height. This was added as of WordPress 2.9 and is used like this:

[embed]...[/embed]

Usage

I have an embedded item, and I want to set max dimensions:

[embed width="123" height="456"]...[/embed]

Note: This shortcode isn't enabled until 'the_content' filter has been processed at least once. If you need to run this shortcode before or without The Loop and aren't using the_content() you'll need to call the following method with the content which contains the [embed] shortcode:

 $GLOBALS['wp_embed']->run_shortcode( 'Content with [embed] shortcode' );

Options

The following basic options are supported:

width
(integer) (optional) Defines width of the media.
Default: None
height
(integer) (optional) Defines height of the media.
Default: None

Source File

The embed shortcode is located in wp-includes/class-wp-embed.php.

Related

WordPress Shortcodes: [audio], [caption], [embed], [gallery], [playlist], [video]