うまくいきました!サポートを再度ありがとうございます
さて、検索機能で見つかり、検索エンジンクローラーによって適切にスクレイピングされるように、トピック内の投稿テキストを非表示に追加したいと考えています。
現在のコード(以下)にどのような変更を加えれば、投稿コンテンツを含む <div style="display:none;">...</div> を追加できますか?
// ショートコードに見えるものをすべて削除します。これにより、投稿内の
// 角括弧 `[...]` で囲まれた部分がすべて削除されます。
add_filter( 'wp_discourse_excerpt', 'testeleven_remove_shortcodes' );
function testeleven_remove_shortcodes( $excerpt ) {
$excerpt = preg_replace( '/\[.*\]/', '', $excerpt );
return $excerpt;
}
// iframe を介して Discourse に埋め込まれた WordPress 投稿を表示する
// https://meta.discourse.org/t/wp-discourse-how-to-deal-with-shortcodes-in-post/58838/5
add_filter( 'discourse_publish_format_html', 'wpdc_custom_discourse_publish_format_html', 10, 2 );
function wpdc_custom_discourse_publish_format_html( $output, $post_id ) {
$permalink = get_the_permalink( $post_id );
ob_start();
?>
<iframe width="690" height="2000" src="<?php echo esc_url( $permalink ); ?>" frameborder="0"></iframe>
<?php
return ob_get_clean();
}