こんな感じでいけると思います。
デザインなどはCSSで適当に調整よろしくお願いいたします。
// 関連記事のフィルターを一旦外す
add_action(
'after_setup_theme',
function() {
remove_filter( 'the_content', 'veu_add_related_posts_html', 800, 1 );
}
);
// 関連記事を表示する
add_action(
'lightning_comment_after', // 関連記事を表示する場所を指定.
function() {
// 関連記事.
if ( function_exists( 'veu_get_related_posts' ) ) {
$post_type = 'post'; // 対象の投稿タイプ
$taxonomy = 'post_tag'; // 関連に紐付けるtaxonomy名
$posts_count = 6; // 表示件数
// 表示したい投稿タイプを指定してください.
if ( get_post_type() == $post_type ) {
// 関連記事を取得.
$posts = veu_get_related_posts( $post_type, $taxonomy, $posts_count );
// 該当する関連記事がある場合.
if ( $posts ) {
echo '<h2 class="p-section-title">関連記事</h2>';
echo '<div class="row">';
foreach ( $posts as $key => $post ) {
echo wp_kses_post( veu_add_related_posts_item_html( $post ) );
}
echo '</div>';
}
wp_reset_postdata();
}
}
}
);