Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created August 22, 2018 23:22
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 AbhishekGhosh/e4a1786726624b672fbdc4b3853c0025 to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/e4a1786726624b672fbdc4b3853c0025 to your computer and use it in GitHub Desktop.
Fat Free Social Share WordPress
<div class="dev-share-buttons">
<a class="button full facebook" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="_blank" rel="nofollow"> Facebook</a>
<a class="button full twitter" href="https://twitter.com/share?text=<?php the_title(); ?>&url=<?php the_permalink(); ?>&via=AbhishekCTRL" target="_blank" rel="nofollow"> Twitter</a>
<a class="button full google" href="https://plus.google.com/share?url=<?php the_permalink(); ?>" onclick="javascript:window.open(this.href,
'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;" target="_blank" rel="nofollow"> Google+</a>
<a class="button full pinterest" href="https://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php
$args = array(
'numberposts' => 1,
'order'=> 'DESC',
'post_mime_type' => 'image',
'post_parent' => $post->ID,
'post_type' => 'attachment'
);
$get_children_array = get_children($args,ARRAY_A); //returns Array ( [$image_ID]...
$rekeyed_array = array_values($get_children_array);
$child_image = $rekeyed_array[0];
$firstimage_attributes = wp_get_attachment_image_src( $child_image['ID'], full );
echo $firstimage_attributes[0];
?>&description=<?php $excerpt = strip_tags(get_the_excerpt());
echo $excerpt; ?>" target="_blank" rel="nofollow"> Pinterest</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment