Site logo

Archived topic

add rel="nofollow" to featured image link

4 replies · Started by Colin on May 27, 2019

Viewing posts 1–5 of 5

Hi,

I need to add rel="nofollow" to the feature image href specified within generate_after_entry_header, generate_featured_image_output.

I see the code within /inc/structure/featured-images.php however I'd prefer not to hack it.

Could you help?

Thank you,

Actually, on 2nd thought I'd like to remove the link all together. Just have it display the image.

Thank you,

Hi there,

Try this PHP snippet:

add_filter( 'generate_featured_image_output', function( $output ) {
    return sprintf( // WPCS: XSS ok.
        '<div class="post-image">
                %2$s
         </div>',
         esc_url( get_permalink() ),
         get_the_post_thumbnail(
             get_the_ID(),
             apply_filters( 'generate_page_header_default_size', 'full' ),
             array(
                 'itemprop' => 'image',
             )
         )
    );
} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

Let me know :)

Perfect, thanks!

No problem :)

This archived topic is closed to new replies.