In this article we'll show you how to include various Pinterest widgets into your WordPress website with shortcode. The widgets are described in more detail on Pinterest's website . The 'Save Button' widget is excluded from the shortcode since standalone function is provided in this article, titled "Add a Pinterest Save Button over Every Image in WordPress". We've reluctantly included the 'Pin' widget into this shortcode since it includes parameters that differ from the other two ('Board' and 'Profile'). However, if you're aware of the differences the added complexity shouldn't be much of an issue.
For the purpose of the examples we'll use our own Pinterest account. Keep in mind that we haven't used the referenced account since early testing of our social media and marketing system.
To render a profile widget we'll use the following:
[pinterestwidget url="https://www.pinterest.com.au/beliefmedia/"] (note that you can include or exclude the country domain extension).
To render a board widget we'll use the following default shortcode:
[pinterestwidget url="https://www.pinterest.com.au/beliefmedia/sydneynews/"]. To make it look a little different from the profile above we'll change the image width. The final shortcode is as follows:
[pinterestwidget url="https://www.pinterest.com.au/beliefmedia/sydneynews/" image="150"]. The result:
The individual pin widget differs in that the
image (size) attributes as described below are not available. Instead, we use
medium (default), and
large. The additional parameter of
description applies for the pin widget (with values of
0 for no, default, or
1 for yes).
The follow button is used in the same manner as the profile widget, except the additional shortcode of
follow="1" applies. To render a follow button for @BeliefMedia we'll use
[pinterestwidget url="https://www.pinterest.com/beliefmedia/" follow="1"]. The result:
The following shortcode attributes are available.
boardwidget only. If no height attribute is provided we'll use the same dimensions as the width (to return a square widget).
pin' widget, you may remove the pin description with
follow="1"along with the URL to return just the follow button (eg:
[pinterestwidget url="https://www.pinterest.com/beliefmedia/" follow="1"])
pinit.js) can be returned with each widget with
sizeonly applies only when rendering the 'Pin' Widget. Available options are
small(236px x 345px),
medium(345px x 426px), and
large(600px x 655px).
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
- Full details on the Pinterest Widgets can be found here . Additional options for rendering Pinterest data (via the API) will be provided in the future.
- While it goes without saying, our Pinterest page isn't very good and isn't really worth following. It was used as an early testing ground for our client social application. We may use it again in the future to further demonstrate the capabilities of our marketing platform.
- The regular expression for each URL matches an optional two-letter domain extension. If you're using any of the newer funky domains, simply alter the expressions as required.