I want to prevent my featured images from being pinnable. Should I add the following to the functions.php file?
/**
* 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 the HTML tag.
$html = str_replace( ‘<img ‘, ‘<img data-pin-nopin=”true” ‘, $html );
return $html;
});