get_post_embed_url()
Retrieves the URL to embed a specific post in an iframe.
Uses: get_permalink()
Used By: get_post_embed_html()
Hooks from the function
Return
String|false
. The post embed URL on success, false if the post doesn't exist.
Usage
get_post_embed_url( $post );
- $post(int|WP_Post)
- Post ID or object.
Default: current post
Examples
#1 What oEmbed link looks like
echo get_post_embed_url( 1 ); // outputs: http://example.com/post-name/embed
#2 Finished embedded view
As an example, let's take the article on this site: https://wp-kama.com/handbook/cheatsheet
and create a manual embed for it, using this URL https://wp-kama.com/handbook/cheatsheet/embed
<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" src="/handbook/cheatsheet/embed" width="600" height="350" style="max-width:600px" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
The result will be this insertion:
The following function exists to create an iframe block automatically for the specified post: get_post_embed_html()
Changelog
Since 4.4.0 | Introduced. |