cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

How To Add a Pinterest Button In WordPress Without Using A Plugin

Today, you’ll learn how to add a Pinterest button to your WordPress site without using a plugin.

This tutorial is made by Marvie Pons of TutsKid and it’s pretty simple and easy to follow. Like with most, if not all WordPress tricks, all it takes is appending a few lines of code in your functions.php file. Simply copy and paste the code below:

function triptripper_pinterest_button($content) {
 global $post, $posts;
 // get image
 $catch_imgs = wp_get_attachment_image_src(get_post_thumbnail_id($post->id), 'large');
 $catch_img = $catch_imgs[0];

 // If there is no featured image or any image, search post for images and display first one. If none exist, display default image
 if($catch_img[0] == ''){
 $out = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $match);
 if ( $out > 0 ){
 $catch_img = $match[1][0];
 } else {
 $catch_img = "/images/default.jpg";

 $get_title = get_the_title();
 $get_link = get_permalink();

$content .= '
<div id="pinterest-wrapper"><a href="'.get_permalink($post->id).'&media='. $catch_img.'&description=' . $get_title . ' on ' . $get_link . '" count-layout="vertical">Pin It</a></div>

return $content;

add_filter('the_content', 'triptripper_pinterest_button');

function triptripper_enqueue_script() {
 wp_enqueue_script('pinterest', '', array(), null, true);

add_action ('wp_enqueue_scripts','triptripper_enqueue_script');     

The first function automatically gets the first image from the post to be pinned and the post’s permalink. And just like with the plugin, it will let you edit the description and the URL before posting. The second function adds the Pinterest JavaScript in your blog’s footer.

If you want to put the horizontal or no count share button, you can simply change the count-layout parameter to horizontal or none. And if you only want to show the button on single posts, pages, and attachment pages, just add the following tag on line 21:

If(is_singular()) {

Then close it with the curly bracket on line 25.

Related Posts

Pinbin Pinned Responsive WordPress Theme

Adding Instagram Badges to Your WordPress Profile

How to Create a Custom WordPress Registration Form with Flat UI

How to Create A Basic Hipster-Style Layout

1 Comment

  1. Bijutoha


    Could you tell me please how will i get functions.php file from my free wordpress site ?