Skip to content

Instantly share code, notes, and snippets.

@FranciscoAMK
Created December 1, 2015 17:52
Show Gist options
  • Save FranciscoAMK/7d420ceb0fdd7fec4ac2 to your computer and use it in GitHub Desktop.
Save FranciscoAMK/7d420ceb0fdd7fec4ac2 to your computer and use it in GitHub Desktop.
Share posts
function apk_share_post($content) {
if( is_single ) {
$content .= '<div class="share-post">
<h4><?php _e("Compartir", "theme_name");?></h4>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" class="facebook" target="_blank">
<i class="fa fa-facebook"></i> Facebook
</a>
<a href="https://twitter.com/intent/tweet?url=<?php the_permalink(); ?>&text=<?php the_title_attribute(); ?>%20por%20@ayudawp" class="twitter" target="_blank">
<i class="fa fa-twitter"></i> Twitter
</a>
<a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" class="googleplus" target="_blank">
<i class="fa fa-google-plus"></i> Google+
</a>
<?php //Obtenemos la URL de la imagen destacada
$pin_imagen = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "large" ); ?>
<a href="https://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php echo $pin_imagen[0]; ?>" class="pinterest" target="_blank">
<i class="fa fa-pinterest"></i> Pinterest
</a>
</div> <!-- /. share-post -->';
}
return $content;
}
add_filter('the_content', 'apk_share_post');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment