Skip to content

Instantly share code, notes, and snippets.

@2shrestha22
Created September 29, 2019 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2shrestha22/980a5fb02a9947a526140eae398ba9c6 to your computer and use it in GitHub Desktop.
Save 2shrestha22/980a5fb02a9947a526140eae398ba9c6 to your computer and use it in GitHub Desktop.
//adds social share in AMP pages add in function.php /WP
add_filter('the_content', 'my_social_share');
function my_social_share($content) {
if(is_single()) {
$before_after_content = '<div class=social-share>
<amp-social-share width=35 height=35 type=facebook data-param-app_id=xxxxxxxxxxxxx></amp-social-share>
<amp-social-share height=35 width=35 type=twitter></amp-social-share>
<amp-social-share height=35 width=35 type="system"></amp-social-share>
</div>';
$share_content = $before_after_content . $content . $before_after_content;
} else {
$share_content = $content;
}
return $share_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment