Adding social links to blog posts sometimes seems like a hassle but actually its not.
Adding it your blog posts is actually quite easy.
There are lots of plugins out there thats does the same but sometimes you want that little extra customization.
The following will be a bit different for certain cases but this should do the trick in general.
If you want to add it to your actual blog post and not the loop you can simply edit the single.php file in your theme folder.
Find where the loop starts, this will normally begin with
while ( have_posts() ) : the_post();
First we want go the details for the specific post to use in the pin it button.
The Details we need are:
1. The Link to the specific article
2. URL to a media file ( image representing the post )
3. Description for the page ( Optional )
Luckily WordPress provides us with some template tags to easily get these
The link we will get using <?php the_permalink(); ?>.
URL We will grab from the featured Image function WordPress provides.
Description we will grab the Post Title by using <?php get_the_title(); ?>
So right after the loop beginning, add the following between php tags
//Url $pinterestUrl = the_permalink(); //Image $image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id() ); $pinterestImg = $image_attributes ; //Description $pinterestTitle = get_the_title();
Next you can add the following code in the spot where you want to display the button.
And thats it, That should give you a pin it button pinning the current post.