I really want to prevent my featured images from being pinned. It seems so simple but I just don't have the knowledge to do it apprently.
I found this but it doesn't work. I have divi theme if that matters.
add_filter( 'post_thumbnail_html', function( $html ){
if ( false !== stripos( $html, 'data-pin-nopin' ) ) {
return $html;
}
// Add 'data-pin-nopin' to the HTML tag.
$html = str_replace( '<img ', '<img data-pin-nopin="true" ', $html );
return $html;
});
I really want to prevent my featured images from being pinned. It seems so simple but I just don't have the knowledge to do it apprently.
I found this but it doesn't work. I have divi theme if that matters.
add_filter( 'post_thumbnail_html', function( $html ){
if ( false !== stripos( $html, 'data-pin-nopin' ) ) {
return $html;
}
// Add 'data-pin-nopin' to the HTML tag.
$html = str_replace( '<img ', '<img data-pin-nopin="true" ', $html );
return $html;
});
Share
Improve this question
edited Mar 30, 2019 at 15:39
ErinandPhillip Santangelo
asked Mar 30, 2019 at 6:24
ErinandPhillip SantangeloErinandPhillip Santangelo
113 bronze badges
2
|
1 Answer
Reset to default 0Simply edit your themes header.php
and place the following snippet between the <head></head>
tags to prevent pinning globally.
<meta name="pinterest" content="nopin" />
Alternatively you can use the Pinterest Block plugin from which offers you more fine-grained control, also for single posts.
This plugin allows you to block selected posts and pages from getting pinned on Pinterest.
Pinterest Block Features
- Blocks pages by inserting the official meta tag from Pinterest. Learn more
- Block specified page types: blog home page, front page, posts, pages, archives.
- Block selected posts and pages.
data-pin-nopin
? – norman.lol Commented Mar 30, 2019 at 8:32