You will need to embed the script code in the head section of the page in which you are using the gif.
<script async custom-element="amp-anim" src="https://cdn.ampproject.org/v0/amp-anim-0.1.js"></script>
There are a number of ways you can do this. Globally using the admin panel provided by the plugin so it appears on every page or using an action in your theme’s function.php file to place it conditionally. In that you can just test for the page and place it if needed.
function my-script-addition() {
if( is_page( 'your page' && is_amp_endpoint() ){
echo '<script async custom-element="amp-anim" src="https://cdn.ampproject.org/v0/amp-anim-0.1.js"></script>';
}
}
add_action( 'amp_post_template_head', 'my-script-addition', 2 );
You may not need the && is_amp_endpoint()
depending on whether you are in AMP takeover or not.
If you are using the genesis framework, all this becomes even easier as they provide header and footer scripts per page already. You would simply put the script declaration into the head for that page. A simple function is then used in your functions.php file to get header and footer scripts to run on a page basis as they normally would on canonical pages in Genesis. This means you don’t need to do things piecemeal and start writing conditions. It becomes very power if you want to start running specific scripts on specific pages or place json structured schema markup on a page per page basis.
-
This reply was modified 6 years, 6 months ago by
frenchomatic.
-
This reply was modified 6 years, 6 months ago by
frenchomatic.
-
This reply was modified 6 years, 6 months ago by
frenchomatic.