[Resolved] add rel="nofollow" to featured image link

Home Forums Support [Resolved] add rel="nofollow" to featured image link

Home Forums Support add rel="nofollow" to featured image link

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #912553
    Colin

    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,

    #912554
    Colin

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

    Thank you,

    #912556
    Leo
    Staff
    Customer Support

    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 ๐Ÿ™‚

    #912558
    Colin

    Perfect, thanks!

    #912562
    Leo
    Staff
    Customer Support
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.