You can for example:
-
Copy the YouTube shortcode from the old theme to your new theme.
Locate the line (most likely in the
functions.php
file):add_shortcode( 'youtube', 'some_function' );
and copy this line and the
some_function()
to yourfunctions.php
in your new
theme or better yet – create a new plugin file including:/*Plugin Name: YouTube embed shortcode from old theme */ add_shortcode( 'youtube', 'some_function' ); some_function( $args = array(), $content=""){ /* ...code... */}
-
Add a YouTube embed plugin with the same parameters.
-
Create your own plugin to handle this.
Here’s a poor man’s version (untested):
/*Plugin Name: YouTube embed shortcode - poor man's version */ add_shortcode( 'youtube', 'ytb_sc' ); if( ! function_exists( 'ytb_sc' ) ): function ytb_sc( $atts = array(), $content="" ) { $atts = shortcode_atts( array( 'id' => '', // default id 'width' => 640, // default width (px) 'height' => 480, // default height (px) ), $atts, 'ytb_sc' ); // Sanitize input: $id = esc_attr( $atts['id'] ); $width = (int) $atts['width']; $height = (int) $atts['height']; if( ! empty( $id ) ) { $sc = sprintf( '%s%s', $width, $height, 'https://www.youtube.com/watch?v=', $id ); } else { return __( 'Missing YouTube ID!' ); } // Output return $GLOBALS['wp_embed']->run_shortcode($sc); } endif;
Hope this helps!