将您的 WordPress 特色图片发送到 Discourse,以便在 Discourse 中点击图片时能返回到 WordPress 文章。以下是我测试有效的方法,希望对您有帮助:
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 = ' [ . ')](' . $url . ')' ;
} else {
$image = "";
} ?>
<?php ob_start(); ?>
<small>原文发表于:{blogurl}</small><br>
<?php echo $title ?><br>
<?php echo $image ?>
<?php $output = ob_get_clean();
return $output;
} ?>