
Enable WP AMP Plugin Suppport for Themes
To enable support for WP AMP plugin please add the following code to your functions.php file:
add_action( 'amp_init', 'invictus_gallery_amp_add_cpt' ); function invictus_gallery_amp_add_cpt() { add_post_type_support( 'gallery', AMP_QUERY_VAR ); }
In addition you have to add this code to add the video iframe (set in the 'invictus_video_embeded_value' custom field ) to AMP gallery posts with this code:
add_action( 'pre_amp_render_post', 'invictus_amp_add_custom_actions' ); function invictus_amp_add_custom_actions() { add_filter( 'the_content', 'invictus_amp_add_video_embed' ); } function invictus_amp_add_video_embed( $content ) { if ( get_post_type() == 'gallery' ) { $video = get_post_meta( get_the_ID(), 'invictus_video_embeded_value', true ); $content = $video . $content; } return $content; }