Prerequisite: Custom Plugin
First you'll need a small plugin. Just copypaste it into a .php
file, add it to some folder, zip and upload it to your installation an you're done.
What it does
This small plugin only checks if the wpembed
query part is present and if it is set to true
. If both is the case and the request looks like for example
https://example.com?wpembed=true
then a custom template will be searched first in your child theme in your parent theme and, if found, will be used instead of any other template from the template hierarchy.
<?php
defined( 'ABSPATH' ) OR exit;
/** Plugin Name: (#102480) WP Embed */
add_action( 'template_redirect', 'wpse_102480_wpembed' );
function wpse_102480_wpembed()
{
if ( isset( $_GET['wpembed'] AND 'true' === $_GET['wpembed'] )
{
include( locate_template( 'wpembed.php' ) );
exit;
}
}
In your (child) theme
Just add another template file to your (child) theme named (in this example) wpembed.php
. There you add whatever you want to be output when it is called. You can access query args via $_GET
parameters or (maybe) even via get_query_var( 'key_name' );
.