Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pinterest 'Pin it' short code for text only link in wordpress blog

I am trying to find a short code that will enable me to add a 'Pin It' (Pinterest), text link to my wordpress blog. I just want a text link only. I don't want to use the graphical button they provide the code for, which is what makes this tricky.

It's very simple to do with Facebook and Twitter. For example:

<a href="http://www.facebook.com/share.php?u=<?php echo get_permalink() ?>" title="Share on Facebook" target="_blank">Facebook,</a>

<a href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" title="Share on Twitter" target="_blank">Twitter,</a>

Does anyone know a way to use a similar line of code for Pinterest? Any guidance is appreciated.

like image 803
Glyph Avatar asked Apr 20 '12 03:04

Glyph


People also ask

How do I link my WordPress blog to Pinterest?

Go to “Settings” and then “Sharing” from your WordPress dashboard. Find the “Sharing Buttons” section and move Pinterest to the “Enabled Services” section. The dropdown menu for Button Style can be used to select “Official Buttons.” This will result in the widely-known Pin It button showing up on your site.

Is there a Pinterest plugin for WordPress?

You can do this — and more — using a Pinterest WordPress plugin. A Pinterest plugin will allow you to add “Pin It” buttons to your images, as well as add a sharing button to your blog posts. Now, let's go over the best Pinterest WordPress plugins you can use on your site right now.

How do I add a pin to my blog?

In return for this effort, you get to choose the image and set the default description for everyone who pins your post from your blog. To add the Pin It button to your blog post: Log into Pinterest (if necessary). In the top right menu, choose About | Pin It Button.


1 Answers

This is what I've done on a site of mine.

/*Stuff for Pinterest*/
    //getting the permalink
$postpermalink = urlencode( get_permalink() );

    //getting the thumbnail
$imageurl = urlencode( wp_get_attachment_url( get_post_thumbnail_id($post->ID) ) );
/*End of Pinterest*/

Then the html:

<a target="blank" href="http://pinterest.com/pin/create/button/?url=<?php echo $postpermalink ?>&media=<?php echo $imageurl ?>" title="Pin This Post">Pin</a>

Hope this helps.

like image 103
AllanT Avatar answered Oct 23 '22 05:10

AllanT