• Resolved primitivenet

    (@primitivenet)


    The AMP plugin is interpreting my YouTube embeds properly (from a custom field), but I get an error saying “The tag ‘amp-youtube’ requires including the ‘amp-youtube’ extension JavaScript.”

    How do I include this JS into the default AMP theme?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Since you’re using the Reader mode and the amp-youtube is appearing outside of the content, you’ll need to add it via this plugin code:

    add_filter(
    	'amp_post_template_data',
    	function( $data ) {
    		$data['amp_component_scripts'] = array_merge(
    			$data['amp_component_scripts'],
    			array(
    				'amp-youtube' => true,
    			)
    		);
    		return $data;
    	}
    );

    This method prevents duplicates from happening.

    Only do this if you’re adding an amp-youtube element to the page.

    Doing this will eventually be unnecessary once this lands: https://github.com/ampproject/amp-wp/issues/2202

    Thread Starter primitivenet

    (@primitivenet)

    Perfect – thank you for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘The tag ‘amp-youtube’ requires including the ‘amp-youtube’ extension JavaScript.’ is closed to new replies.