That’s strange. Your code looks fine. Though, if I may suggest, use a different hook.
That said, can you try hooking it elsewhere?
Try this code out. This should display the comment count after entry header.
add_filter( 'generate_after_entry_header', 'change_author_to_comments' );
function change_author_to_comments()
{
if ( is_single() ) {
echo '| <span class="comments-links">';
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span>';
}
}
Let us know how it goes.
A wise man once said:
"Have you cleared your cache?"