Verlinke ein hervorgehobenes Bild zurück zu seinem Wordpress-Beitrag

Senden Sie Ihr Beitragsbild von WordPress an Discourse, damit beim Klicken auf das Bild in Discourse zur WordPress-Seite zurückgeleitet wird. Hier ist eine Lösung, die bei mir funktioniert. Ich hoffe, sie hilft Ihnen:

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>Ursprünglich veröffentlicht auf: {blogurl}</small><br>
        <?php echo $title ?><br>
        <?php echo $image ?>
        <?php $output = ob_get_clean();
        return $output;
    } ?>
2 „Gefällt mir“