Add the below code in the functions.php file and it will create a text field in the general setting options page
add_action('admin_init', 'embed_url_initialize');
function embed_url_initialize() {
// First, we register a section. This is necessary since all future options must belong to one.
add_settings_section(
'general_settings_section', // ID used to identify this section and with which to register options
'Embed Url Option', // Title to be displayed on the administration page
'embed_url_general_options_callback', // Callback used to render the description of the section
'general' // Page on which to add this section of options
);
// Next, we will introduce the fields for toggling the visibility of content elements.
add_settings_field(
'video_url', // ID used to identify the field throughout the theme
'Enter Video Url', // The label to the left of the option interface element
'video_url_callback', // The name of the function responsible for rendering the option interface
'general', // The page on which this option will be displayed
'general_settings_section' // The name of the section to which this field belongs
);
// Finally, we register the fields with WordPress
register_setting(
'general',
'video_url'
);
}
/* ------------------------------------------------------------------------ *
* Section Callbacks
* ------------------------------------------------------------------------ */
/**
* This function provides a simple description for the General Options page.
*
* It is called from the 'embed_url_initialize' function by being passed as a parameter
* in the add_settings_section function.
*/
function embed_url_general_options_callback() {
echo '<p>Please enter the embed url.</p>';
} // end embed_url_general_options_callback
/* ------------------------------------------------------------------------ *
* Field Callbacks
* ------------------------------------------------------------------------ */
/**
* This function renders the interface element for input embed url.
*/
function video_url_callback($args) {
$html="<input type="textbox" class="regular-text" id="video_url" name="video_url" value="" . get_option("video_url") .'" />';
echo $html;
} // end video_url_callback_callback
then call the below code in the template file where you want to get the embed video
<?php if(get_option('video_url')) {
$embed = wp_oembed_get( get_option('video_url') );
if( $embed ) {
echo $embed;
} else {
// The embed HTML couldn't be fetched
}
} // end if ?>