WordPress at a glance

get_post_embed_url() WP 1.0

Retrieves the URL to embed a specific post in an iframe.

Is the basis for: get_post_embed_html()
Works based on: get_permalink()
Hooks from 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

Code of get_post_embed_url: wp-includes/embed.php VER 4.9.8

<?php
function get_post_embed_url( $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	$embed_url     = trailingslashit( get_permalink( $post ) ) . user_trailingslashit( 'embed' );
	$path_conflict = get_page_by_path( str_replace( home_url(), '', $embed_url ), OBJECT, get_post_types( array( 'public' => true ) ) );

	if ( ! get_option( 'permalink_structure' ) || $path_conflict ) {
		$embed_url = add_query_arg( array( 'embed' => 'true' ), get_permalink( $post ) );
	}

	/**
	 * Filters the URL to embed a specific post.
	 *
	 * @since 4.4.0
	 *
	 * @param string  $embed_url The post embed URL.
	 * @param WP_Post $post      The corresponding post object.
	 */
	return esc_url_raw( apply_filters( 'post_embed_url', $embed_url, $post ) );
}

Related Functions

From tag: oEmbed (WP response to embed request)

More from tag: Link (URL)

More from category: Other

No comments
    Hello, !     Log In . Register