I was told to do this code in my the theme’s functions.php file. I tried it and it would not work.
What should I do? Is there an easier way?
/**
- Disable pinning of all featured images.
*/
add_filter( ‘post_thumbnail_html’, function( $html ){
// Something already has ‘data-pin-nopin’, so we don’t need to modify.
if ( false !== stripos( $html, ‘data-pin-nopin’ ) ) {
return $html;
}
// Add ‘data-pin-nopin’ to theHTML tag.
$html = str_replace( '<img ', '<img data-pin-nopin=“true” ', $html );
return $html;
});