Skip to content

Instantly share code, notes, and snippets.

@johnregan3
Last active September 28, 2016 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnregan3/de2318406bfbe535525885bce1657b98 to your computer and use it in GitHub Desktop.
Save johnregan3/de2318406bfbe535525885bce1657b98 to your computer and use it in GitHub Desktop.
Example AMP Social Share buttons in WordPress
<?php
/*
* Example of using amp-social-share within WP.
*
* Note that Facebook requires an App ID {YOUR_FB_APP_ID}.
*
* Be sure to include the amp-social-share component script.
*/
<div class="share-buttons">
<amp-social-share type="facebook" width="32" height="32"
data-url="<?php echo esc_url( get_permalink() ); ?>"
data-param-app_id="<?php echo esc_attr( {YOUR_FB_APP_ID} ); ?>"
data-media="<?php echo esc_url( wp_get_attachment_url( get_post_thumbnail_id() ) ); ?>"
data-description="<?php the_title_attribute(); ?>">
</amp-social-share>
<amp-social-share type="twitter" width="32" height="32"
data-url="<?php echo esc_url( get_permalink() ); ?>"
data-media="<?php echo esc_url( wp_get_attachment_url( get_post_thumbnail_id() ) ); ?>"
data-description="<?php the_title_attribute(); ?>">
</amp-social-share>
<amp-social-share type="pinterest" width="32" height="32"
data-url="<?php echo esc_url( get_permalink() ); ?>"
data-media="<?php echo esc_url( wp_get_attachment_url( get_post_thumbnail_id() ) ); ?>"
data-description="<?php the_title_attribute(); ?>">
</amp-social-share>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment