Implementing Pinterest Follow Button in WordPress Plugin

Posted on 17th June 2023

Overview

This guide covers how to implement the Pinterest Follow Button in a WordPress plugin. The Follow Button lets people follow you on Pinterest and see the pins you save. Pins you save from a website will include a link back to that site, and the Pinterest widget will show the number of people who have saved the Pin. If you’re a plugin developer, you can use the Follow Button to let people follow your plugin on Pinterest. You can also use it to let people follow a board or profile related to your plugin. For example, if your plugin is a recipe plugin, you might have a board with recipes that people can follow. The Follow Button is available in two sizes: small and large. You can also customize the color of the Button to match your website.

Getting Started

To get started, you’ll need to create a Pinterest app. Once you’ve created your app, you can get the code for the Follow Button from the Pinterest developer website. Once you have the code, you can add it to your plugin. You can also use the Follow Button without an app, but we recommend creating an app so you can track the number of people who follow you on Pinterest.

Creating a Pinterest App

To create a Pinterest app, you’ll need a Pinterest account. If you don’t have a Pinterest account, you can sign up for one at https://www.pinterest.com. Once you have a Pinterest account, you can create an app by going to the Pinterest developer website and clicking “Create App”.

You’ll need to provide a name and description for your app. You can also upload a logo for your app. Once you’ve created your app, you’ll be given an App ID and App Secret. You’ll need these when you get the code for the Follow Button.

Getting the Code for the Follow Button

Once you’ve created your Pinterest app, you can get the code for the Follow Button from the Pinterest developer website. To do this, go to the Pinterest developer website and click on the “Follow Button” tab. You’ll be asked to provide your App ID and App Secret. Once you’ve provided these, you’ll be given the code for the Follow Button.

You can then add this code to your plugin. We recommend adding it to a file called “pinterest-button.php” in your plugin’s directory. You can then include this file in your plugin. Alternatively, you can add the code to your plugin’s main file.

Adding the Follow Button to Your Plugin

Once you have the code for the Follow Button, you can add it to your plugin. To do this, you’ll need to edit your plugin’s code. You can do this using a text editor such as Notepad++ or Sublime Text. Once you’ve opened your plugin’s code in a text editor, you’ll need to find the “pinterest-button.php” file. You can do this by searching for “pinterest-button.php” in the text editor. Once you’ve found the file, you’ll need to add the following code to it:

<?php

// Pinterest Follow Button

function pinterest_button_func( $atts ) {

extract( shortcode_atts( array(

'user' => '',

'board' => '',

'size' => 'small',

'color' => 'red',

), $atts ) );

return '<a href="https://www.pinterest.com/'.$user.'/'.$board.'/" data-pin-color="'.$color.'" data-pin-height="28" data-pin-do="buttonFollow"><img src="//assets.pinterest.com/images/pidgets/follow_me_on_pinterest_button.png" /></a>';

}

add_shortcode( 'pinterest-button', 'pinterest_button_func' );

?>

This code will add the Follow Button to your plugin. You can then use the Follow Button by adding the following code to your posts and pages:

[pinterest-button user="username" board="boardname" size="small" color="red"]

You can also use the Follow Button without an app. To do this, you’ll need to remove the App ID and App Secret from the code. You can do this by removing the following lines from the code:

// Pinterest Follow Button

function pinterest_button_func( $atts ) {

extract( shortcode_atts( array(

'user' => '',

'board' => '',

'size' => 'small',

'color' => 'red',

), $atts ) );

return '<a href="https://www.pinterest.com/'.$user.'/'.$board.'/" data-pin-color="'.$color.'" data-pin-height="28" data-pin-do="buttonFollow"><img src="//assets.pinterest.com/images/pidgets/follow_me_on_pinterest_button.png" /></a>';

}

add_shortcode( 'pinterest-button', 'pinterest_button_func' );

?>

You can then use the Follow Button by adding the following code to your posts and pages:

[pinterest-button user="username" board="boardname" size="small" color="red"]

Replace “username” with your Pinterest username and “boardname” with the name of the board you want people to follow. You can also change the size and color of the Follow Button. The size can be “small” or “large”, and the color can be “red”, “white”, or “gray”.

Conclusion

In this guide, we’ve covered how to implement the Pinterest Follow Button in a WordPress plugin. We’ve also covered how to create a Pinterest app and how to get the code for the Follow Button. You can then use the Follow Button by adding it to your posts and pages. You can also use the Follow Button without an app, but we recommend creating an app so you can track the number of people who follow you on Pinterest.

Step 3: Add the Follow Button to Your Plugin

Now that you have the follow button code, you need to add it to your plugin. The code will go in your plugin’s main PHP file. If you’re using a code editor like Sublime Text, make sure you open your plugin in that editor.

Once your plugin is open in your code editor, look for the <div> with the class pinterest-follow-button. This is where you’ll add the follow button code. The code should look something like this:

<div class="pinterest-follow-button">

// Follow button code goes here

</div>

Once you’ve added the follow button code, you need to save your plugin and upload it to WordPress. You can do this by going to the Plugins menu and selecting Add New. On the Add New page, click the Upload Plugin button. Then, select your plugin’s ZIP file and click Install Now. WordPress will now upload and install your plugin.

Once your plugin is installed, you need to activate it. You can do this by going to the Plugins menu and selecting Installed Plugins. On the Installed Plugins page, find your plugin and click the Activate link. Your plugin is now activated.

Now that your plugin is activated, the follow button will appear on your website. If you want to change the position of the button, you can do so by editing your plugin’s code. You can also change the button’s appearance by editing the CSS code in your plugin.

Step 4: Test Your Plugin

Once you’ve added the follow button to your plugin, you need to test it to make sure it works. The best way to do this is to install the plugin on a test site. This will allow you to test your plugin without affecting your live site.

To install your plugin on a test site, you first need to create a new WordPress site. You can do this by going to the Tools menu and selecting Create a New Site. On the Create a New Site page, enter your site’s URL, name, and description. Then, click the Create Site button.

Once your test site is created, you need to install and activate your plugin. You can do this by going to the Plugins menu and selecting Add New. On the Add New page, click the Upload Plugin button. Then, select your plugin’s ZIP file and click Install Now. WordPress will now upload and install your plugin.

Once your plugin is installed, you need to activate it. You can do this by going to the Plugins menu and selecting Installed Plugins. On the Installed Plugins page, find your plugin and click the Activate link. Your plugin is now activated.

Now that your plugin is activated, the follow button will appear on your test site. You can now test your plugin to make sure it works. Once you’ve tested your plugin and it’s working, you can delete your test site. You can do this by going to the Tools menu and selecting Delete Site.

Step 5: Customize Your Plugin

Now that your plugin is working, you can customize it to match your website’s design. If you want to change the position of the follow button, you can do so by editing your plugin’s code. You can also change the button’s appearance by editing the CSS code in your plugin.

If you want to change the position of the follow button, you need to edit your plugin’s <div> tag. The <div> tag is located in your plugin’s main PHP file. To change the position of the button, you need to add the following code to the <div> tag:

<div class="pinterest-follow-button" style="position: absolute; top: 10px; left: 10px;">

// Follow button code goes here

</div>

This code will position the follow button 10px from the top and 10px from the left of your website. You can change these values to position the button anywhere on your website.

If you want to change the appearance of the follow button, you need to edit the CSS code in your plugin. The CSS code is located in your plugin’s style.css file. To change the button’s color, you need to add the following code to the style.css file:

.pinterest-follow-button {

background-color: #fff;

}

You can change the #fff to any color code. This will change the background color of the button. You can also change the button’s text color by adding the following code to the style.css file:

.pinterest-follow-button a {

color: #000;

}

You can change the #000 to any color code. This will change the text color of the button. You can also change the button’s border color by adding the following code to the style.css file:

.pinterest-follow-button {

border: 1px solid #000;

}

You can change the #000 to any color code. This will change the border color of the button.

Step 6: Update Your Plugin

Once you’ve customized your plugin, you need to update it. You can do this by going to the Plugins menu and selecting Update. On the Update page, select your plugin’s ZIP file and click Update. WordPress will now update your plugin.

Once your plugin is updated, the follow button will appear on your website with your customizations. If you want to change the position of the button, you can do so by editing your plugin’s code. You can also change the button’s appearance by editing the CSS code in your plugin.