Home › Forums › Support › Add rel nofollow to featured image This topic has 5 replies, 2 voices, and was last updated 4 years, 4 months ago by David. Viewing 6 posts - 1 through 6 (of 6 total) Author Posts December 6, 2019 at 6:07 pm #1096549 Phuoc Hello support, I need help to add rel nofollow to featured image link in Category. I don’t want to remove featured image link, only make it nofollow. Thanks December 7, 2019 at 4:22 am #1096806 DavidStaff Customer Support Hi there, try this PHP snippet: add_filter( 'post_thumbnail_html', 'db_post_thumb_nofollow', 10, 3 ); function db_post_thumb_nofollow( $html, $post_id, $post_image_id ) { $html = '<a href="' . get_permalink( $post_id ) . '" rel="nofollow" >' . $html . '</a>'; return $html; } Adding PHP: https://docs.generatepress.com/article/adding-php/ Reference: https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/#linking-to-post-permalink-or-larger-image December 14, 2019 at 5:47 am #1104072 Phuoc Thanks David, The featured image link in category nofollow, but this code insert future image link in in single post too December 14, 2019 at 6:01 am #1104083 DavidStaff Customer Support Try: add_filter( 'post_thumbnail_html', 'db_post_thumb_nofollow', 10, 3 ); function db_post_thumb_nofollow( $html, $post_id, $post_image_id ) { if ( is_single() || is_page() || is_front_page() ) { return $html; } else { $html = '<a href="' . get_permalink( $post_id ) . '" rel="nofollow" >' . $html . '</a>'; return $html; } } December 15, 2019 at 12:07 am #1104687 Phuoc featured image of Homepage still have link December 15, 2019 at 6:02 am #1104846 DavidStaff Customer Support Code updated here Author Posts Viewing 6 posts - 1 through 6 (of 6 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In