Hyperlink Comment count | WordPress.org

It may be different in your theme, but in twentytwentyone, comments are in a div with the ID “comments”. So

echo ‘ – ‘, <a href="#comments">get_comments_number(), ‘ comments ‘, '</a>';

Hi Intentional Farm,
Steven’s suggestion will work on single post pages (once the syntax errors are corrected ( vs. ')). For the comment links on your home page the href value needs to include the current post’s permalink. So:
echo ' – <a href="', esc_url( get_permalink()), '#comments">', get_comments_number(), ' comments</a>';

This community rocks! Thanks so much for you speedy suggestions. bcworkz, the home page code worked

Thanks Steven for the single post info too.

Appreciate you both.

Source link