• Hello,

    I’ve got this custom function, that wraps my the_post_thumbnail() inside anchor tag:

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    
    	return $html;
    }

    Then i simply call it in code by doing the_post_thumbnail() ofcourse. I’d like to give my function additional parameters $is_link, so when i would call the_post_thumbnail($is_link = false), it would return the thumbnail without wraping it inside of a link.

The topic ‘Modify the_post_thumbnail so it takes additional parameter’ is closed to new replies.