Tag - Button

How to Add Pinterest “Pin It” Button in WordPress (Ultimate Guide)


Do you want to add the Pinterest “Pin It” button in WordPress? Recently, a new traffic source popped up in our blog stats.

It was significant enough for us to take notice. This traffic source was Pinterest.

Pinterest is a popular social networking site that allows you to share visual content and drive a lot of traffic to your website (follow WPBeginner on Pinterest).

In this article, we will show you how to add the Pinterest “Pin It” button to your WordPress blog. We will also explain how to add the Pin It button over the images of your website.

Add Pinterest Pin It button in WordPress

Adding a Pinterest “Pin It” Button Using a Plugin

Pinterest officially changed the “Pin It” button name to Save in 2016.

Although some plugins still use the name “Pin It” instead of Save, they do the same job of pinning your images to Pinterest.

The easiest way to add a Pinterest button to your WordPress site is by using a social sharing plugin.

We recommend using Shared Counts plugin for this purpose. It is the best social media plugin for WordPress because it’s free and allows you to easily add the Pinterest button along with other popular social networks.

To get started, you need to install and activate the Shared Counts plugin. You can follow our step by step guide on how to install a WordPress plugin for detailed instructions.

Upon installation, head over to Settings » Shared Counts page to configure the plugin.

Shared Counts settings page

On the settings page, you need to scroll down to the Display section and then click on the “Share Buttons to Display” textbox.

This will open a dropdown menu where you can select the social media services you want to add. By default, Pinterest will be present in that box, along with Facebook and Twitter.

You can also select the location and post type where you want to display the Pinterest button. It comes with multiple button styles that you can choose from the ‘Share button style’ option.

Once you are done, don’t forget to click on the Save Changes button to store the settings.

You can now visit any post on your website to see the Pinterest button in action.

Pinterest button added to WordPress post

Another neat thing about SharedCounts is the free Custom Pinterest Image addon available on Github. This lets you set a custom Pinterest sharing image and description that’s optimized for Pinterest.

Note: We use SharedCount plugin on our website because it’s the best option in the market. It’s very well-coded and it’s free.

Manually Adding a Pinterest Pin It Button in WordPress

Some intermediate users may prefer to add the social sharing buttons manually to their WordPress site instead of using a plugin.

Let’s take a look at how to manually add a Pinterest button in WordPress.

The first thing you need to do is make a complete WordPress backup of your site. This will help you restore your site in case something breaks by accident.

Next, you need to connect to your WordPress hosting using an FTP client and then go to the /wp-content/themes/ folder.

From here, you need to open your current theme folder and then locate the footer.php file.

Download footer php file

Next, simply right-click on that file and then select Download from the menu. This will download the footer.php file to your computer.

Now you need to open the footer.php file using a plain text editor like Notepad and then paste the following script right before the </body> tag.


<script type="text/javascript">
(function() 
    window.PinIt = window.PinIt )();
</script>

Once you have done that, you need to save the file and then upload it back to the current theme folder.

Next, you need to locate and download the single.php file from your theme folder and open it for editing. After that you need to add the following code.

You will need to choose the location where you want it to appear in your post. After post title is the most common placement for social media buttons.


<?php $pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
<a href="http://pinterest.com/pin/create/button/?url=<?php echo urlencode(get_permalink($post->ID)); ?>&media=<?php echo $pinterestimage[0]; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="vertical">Pin It</a>

The above code displays the Pinterest button with your featured image, title, description, and post URL in the share URL parameter.

Finally, you need to save the file and upload it back to your theme directory using FTP.

This will add a vertical share button to the posts of your website. If you want to display the horizontal share button, then simply change the count-layout parameter to horizontal.

Creating a Shortcode for Pinterest Button

Recently, one of our users asked us how to create a shortcode for the Pinterest “Pin It” button.

Shortcodes in WordPress allow you to easily add dynamic items to your WordPress posts, pages, and widgets. By creating a shortcode, you’ll be able to manually add Pinterest button in your articles.

First, you’ll need to add the following code to your theme’s functions.php file or a site-specific plugin:



function get_pin($atts) 
$pinterestimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
return '<a href="http://pinterest.com/pin/create/button/?url=' . urlencode(get_permalink($post->ID)) . '&media=' . $pinterestimage[0] . '&description=' . get_the_title() .'" class="pin-it-button" count-layout="vertical">Pin It</a>'; 

add_shortcode('pin', 'get_pin');

After that, you can use the [pin] shortcode in your WordPress posts where you want to display the Pinterest button.

Adding Pinterest Pin It Button Over Your Images

If you are running a fashion, photography, or portfolio site, then you definitely want your images to be shared on Pinterest to increase your website traffic.

Let’s take a look at how to add the Pinterest Pin it button over your images in WordPress. This button will appear only when the user brings their mouse over your images, allowing them to easily share the image on their Pinterest profile.

First, you need to install and activate the Pinterest Pin it Button for Images plugin.

Upon activation, go to Settings » Pinterest Pin It page to configure the plugin.

Pinterest Pin It button for images settings page

On the settings page, you can choose where you want to show the “Pin It” button on your WordPress site. You can display it only on single posts, pages, category pages, or everywhere on your site.

The next option is to choose the default description from the dropdown menu. This will be used as the image description for the pinned image.

Once done, you need to click on the Save button to store the settings. Now you can visit your website and then hover your mouse cursor over any image to see the Pinterest “Pin It” button.

Pinterest Pin It button over images

If you want to exclude some images from showing the Pin It button, then you can add the nopin CSS class to the images you want to exclude.

To do that, you need to select the image block in the post editor and then click on the 3 vertical dots icon from the block toolbar. This will open a menu where you need to click on the Edit as HTML option.

Edit Image as HTML option to add CSS class

You will now see the HTML code of your image. Go ahead to add nopin to the class attribute of the img tag:

<figure class="wp-block-image"><img src="https://example.com/wp-content/uploads/2019/06/imagename.jpg" alt="image name" class="nopin wp-image-1687"/></figure>

Similarly, you can also use the plugin to disable automatic display of the “Pin It” button, and use the CSS class “pinthis” to selectively display the button on specific images.

To do that, you need to visit the plugin’s settings page and then locate the Advanced section on the right side of the page.

Pinterest Pin It plugin advanced settings

Now you need to check the option that says ‘Show “Pin it” button only on images with class=”pinthis” ‘, and then click on the Save button.

The next time you add an image to a post or page, you need to select the image block and then use the Edit as HTML option to add the pinthis CSS class to the image code. Here is an example:

<figure class="wp-block-image"><img src="https://example.com/wp-content/uploads/2019/06/imagename.jpg" alt="image name" class="pinthis wp-image-1687"/></figure>

This will show the Pinterest button on that specific image, even if you have disabled the option to automatically show the Pin It button on your site.

That’s all!

We hope this article helped you understand how to add a Pinterest “Pin It” button to your WordPress blog. You may also want to see our guide on how to create an email newsletter and get more subscribers.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.



Source link

How to Add Stripe Donate Button in WordPress (with Recurring Option)


Do you want to add a Stripe donate button to your WordPress site? Stripe is one of the best online payment processors in the world because it allows anyone to easily accept online payments on their website including donations.

In the past, you had to use an eCommerce plugin to accept payments, but that’s not needed anymore specially if you want to collect donations or sell a few products. You can use a simple payment form to do the job.

In this article, we will show you how to easily add a Stripe donate button in WordPress.

Adding a Stripe donate button in WordPress posts and pages

What You Need to Accept Stripe Donations on Your Website

You’ll need to create a Stripe account. You can create an account for free and will only be charged for transactions.

You’ll also need a WordPress website with SSL enabled. SSL adds a security layer to your website making it safe for accepting payments. To learn more, see our guide on how to get a free SSL certificate for your website.

Lastly, you’ll need a WordPress extension to connect your Stripe account. We’ll be using WPForms, which is the best WordPress form plugin.

It comes with a Stripe addon that allows you to accept donations, one-time payments, and even subscription payments on your website. You’ll need at least their PRO plan to access the Stripe add-on.

That being said, let’s take a look at how to add a Stripe donate button in WordPress.

Adding The Stripe Donate Button in WordPress

First thing you need to do is install and activate the WPForms plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit WPForms » Settings page to enter your license key. You can find this information, under your account on WPForms website.

Add WPForms license key

Next, you need to visit WPForms » Addons page and click on the ‘Install Addon’ button next to the Stripe addon.

Install Stripe addon

WPForms will now install and activate the Stripe add-on for you.

Now let’s connect WPForms to your Stripe account to receive payments. To do that you need to visit WPForms » Settings page and click on the Payments tab.

Stripe payment settings

You will be asked to enter your Stripe API keys, which you can find under your Stripe dashboard.

Simply log in to your Stripe account dashboard and from the left menu select Developers » API Keys.

Stripe API keys

You need two pairs of keys for the published website and for testing.

First, you’ll see the publishable keys on the screen. Copy and paste the public key and then click on ‘Reveal key token’ to copy and paste the publishable secret key.

Stripe publishable keys

Next, you need to add the test keys. Click on the ‘View test data’ toggle and then copy and paste the test API keys.

Test api keys

Now that you have pasted the API keys, you can optionally enable the test mode from payment settings.

This will allow you to test Stripe integration without actual payments. However, you must uncheck this option when your website is ready for accepting donations on your website.

Stripe keys in WPForms

Don’t forget to click on the ‘Save settings’ button to store your changes.

Now that you have set up the payments, it is time to create a Stripe donate form for your website.

Making a Stripe Donation Form in WordPress

First, you need to visit the WPForms » Add New page to create a new form. You will be asked to provide a title for your form and choose a template. You need to select the ‘Donation Form’ template.

Create a donation form

This will launch the WordPress forms builder interface with your selected donations form template. This template will already have the common fields required to create a donation form like name, email, donation amount, and message.

Editing the donation form in WPForms

This is a drag and drop form builder. You can edit form fields by clicking on them, rearrange them, or add new fields from the left column.

Since you are creating a Stripe payments form, you need to add a credit card field to your form. You’ll find it under ‘Payments Fields’ section on the left column.

Adding Stripe credit card field to your form

Simply click to add the field to your form and then drag and drop to rearrange its position in the form.

Once you are satisfied with the form, click on the Payments tab in the left corner to edit the payment settings. From here you need to select Stripe as your payment method and then check the box next to ‘Enable Stripe Payments’ option.

Enable payment option

You can provide a description for the payment and select the email field if you want to send the donors a receipt of the payment.

WPForms also supports recurring payments. You can use this option to set up recurring donations or subscriptions.

The next step is to setup confirmation settings. This is what your users will see after they fill the form.

Click on the Settings tab and then select the confirmation option.

Set up confirmation

From here you can select different types of confirmation options. For example, you can thank users with a simple message, or redirect them to a thank you page or any other URL.

Once done, click on the save button and exit the form builder.

Adding The Stripe Donation Form in WordPress

WPForms makes it super easy to add your forms anywhere on your website.

Simply edit the post or page where you want to add the donation form. Next, add the WPForms block to your content and select the donation form you created earlier.

Add donation form to your WordPress post or page

WPForms will now fetch and embed the form for you. You can now visit your website to see it in action.

Stripe donation form preview

You can also add the donation form to your blog’s sidebar or any other widget ready area. Head over to Appearance » Widgets page and add WPForms widget to a sidebar.

Adding a donation form to sidebar

Next, you need to select your Stripe donation form in the widget settings. Don’t forget to click on the Save button to store your widget settings.

We hope this article helped you easily add a Stripe donate button to your WordPress site. You may also want to see our guide on the must have WordPress plugins for every website.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add Stripe Donate Button in WordPress (with Recurring Option) appeared first on WPBeginner.



Source link