Jump-to-Comments Link in the Middle of Posts
Adds a small "Join the discussion" link with the comment count halfway through posts, so engaged readers find the comments faster.
Opens WPIDE on
Code
<?php if ( is_single() && ( comments_open() || get_comments_number() ) ) : ?>
<p class="wpide-jump-to-comments" style="margin:1.5em 0;padding:.6em 1em;border-radius:6px;background:rgba(127,127,127,.08)">
<a href="#respond">
<?php
$wpide_count = (int) get_comments_number();
echo esc_html( $wpide_count ? sprintf( _n( 'Join the discussion: %s comment so far', 'Join the discussion: %s comments so far', $wpide_count ), number_format_i18n( $wpide_count ) ) : 'Have a thought? Be the first to comment' );
?>
↓
</a>
</p>
<?php endif; ?>
Notes
Links to the comment form (#respond), which exists in classic and block themes.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.