Set Featured Image to Pinterest NoPin
Disclosure: Please note that this article may contain affiliate links. You can read my full disclosure here.
Need help with the Tech-side of blogging? Join my Facebook Group and get some answers.If you like to set your blog Pinterest image as an Optimized Pinterest Image, then for your Featured Image you may be in tight spot.
You can set the Featured Image as your Optimized Tall Pinterest image, which may not suit you blog best, but keeps Pinterest happy for sending decent traffic.
Or
You can look for your theme’s template file that sets the image and add data-pin-nopin attribute.
Or
You can just leave it be and allow visitors to pin the featured image if they so choose, even though it is not optimized for Pinterest.
I chose the 2nd option for our main blog as Pinterest is our biggest traffic driver and having properly optimized Pins is fairly important.
Which theme are you using? I’ll show you how I found the template file to modify for a few different themes so you will get the idea.
Links will open in a new tab so you don’t lose your place.
How to find and edit your theme files
This is an advanced tutorial since it is modifying theme files. If you find that this is a bit too complicated and you’d like a professional to handle this for you, you can take a look at my services page and we can arrange to do a remote screen sharing session together.
Astra Theme
Make sure to backup your blog first in case you make a mistake in the cPanel files, so you have a backup you can restore.
You will need to login to your host and access the cPanel and open the file explorer.
In your Astra Theme folder
Click on the folder named inc
Then right-click on extras.php and select download to save the original.
Then right-click on extras.php and select edit
Search for the following text:
‘itemprop’ => ‘image’,
You will see the following:
'astra_featured_image_markup',
get_the_post_thumbnail(
get_the_ID(),
apply_filters( 'astra_post_thumbnail_default_size', 'large' ),
array(
'itemprop' => 'image',
)
)
);
Add the following ‘data-pin-nopin’ => ‘true’,
It will look like this:
'astra_featured_image_markup',
get_the_post_thumbnail(
get_the_ID(),
apply_filters( 'astra_post_thumbnail_default_size', 'large' ),
array(
'itemprop' => 'image', 'data-pin-nopin' => 'true',
)
)
);
Then save the file.
If you are using caching you may need to clear the cache – this can be browser cache, WordPress site cache, and/or host cache.
Ocean WP
Set Single Post Featured Image to nopin
Ocean WP allows your author image, related posts images and featured image to be pinned, if you want to disable these with the Pinterest nopin attribute see the following instructions.
Open the theme folder OceanWP, then open the folder Partials, then folder Singles, then folder media.
Then right-click on blog-single.php and select download to save the original.
Then right-click on blog-single.php and select edit
Search for ‘alt’ => get_the_title(), then on the line below add ‘data-pin-nopin’ => ‘true’
Before:
$img_args = array(
'alt' => get_the_title(),
);
After:
$img_args = array(
'alt' => get_the_title(),
'data-pin-nopin' => 'true'
);
Set Related Posts to nopin
Open the theme folder OceanWP, then open the folder Partials, then folder Singles
Then right-click on related-posts.php and select download to save the original.
Then right-click on related-posts.php and select edit
Search for ‘alt’ => get_the_title(), then on the line below add ‘data-pin-nopin’ => ‘true’
Before:
$img_args = array(
'alt' => get_the_title(),
);
After:
$img_args = array(
'alt' => get_the_title(),
'data-pin-nopin' => 'true'
);
Set Latest Posts to nopin
Open the theme folder OceanWP, then open the folder Partials, then folder Entry, then the folder Media
Search for ‘alt’ => get_the_title(), then on the line below add ‘data-pin-nopin’ => ‘true’
Before:
$img_args = array(
'alt' => get_the_title(),
);
After:
$img_args = array(
'alt' => get_the_title(),
'data-pin-nopin' => 'true'
);
Set Author Bio Box to nopin
This one is a bit more complicated as it is coming from the get_avatar code rather than the the_post_thumbnail.
Open the theme folder OceanWP, then open the folder Partials, then folder Singles
Then right-click on author-bio.php and select download to save the original.
Then right-click on author-bio.php and select edit
Search for get_avatar
Before:
<?php
// Display author avatar
echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'ocean_author_bio_avatar_size', 100 ) ); ?>
</a>
After:
<?php
// Display author avatar
echo get_avatar( get_the_author_meta( 'user_email' ), $size = '100','','', array('extra_attr' => 'data-pin-nopin="true"')); ?>
</a>
This post is to be continued.