# Link a featured image back to its Wordpress post

**URL:** https://meta.discourse.org/t/link-a-featured-image-back-to-its-wordpress-post/192560
**Category:** Administrators
**Tags:** wordpress, how-to
**Created:** [June 3, 2021, 1:46pm UTC](https://meta.discourse.org/t/link-a-featured-image-back-to-its-wordpress-post/192560 "2021-06-03T13:46:38Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RichardC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/richardc/32/216860_2.png) [@RichardC](https://meta.discourse.org/u/RichardC)
#### Post date: [June 3, 2021, 1:46pm UTC](https://meta.discourse.org/t/link-a-featured-image-back-to-its-wordpress-post/192560/1 "2021-06-03T13:46:38Z")

</div>

Send your featured image from Wordpress to Discourse so that clicking on the image in Discourse takes you back to the wordpress post. Here’s what works for me. Hope it helps:

```plaintext
add_filter( 'discourse_publish_format_html', 'my_custom_publish_format', 10, 2 );

function my_custom_publish_format( $output, $post_id ) {
  $post = get_post( $post_id );
  $title = get_the_title($post->ID);
  $url = get_permalink($post->ID);
  if ( has_post_thumbnail( $post_id ) ) {
	$image = ' [![' . $title . '](' . get_the_post_thumbnail_url( $post->ID, 'medium' ) . ')](' . $url . ')' ;
  } else {
	$image = "";
  } ?>

       <?php ob_start(); ?>
	<small>Originally published at: {blogurl}</small><br>
        <?php echo $title ?><br>
        <?php echo $image ?>
        <?php $output = ob_get_clean();
        return $output;
    } ?>

```
