Skip link (or Skip Navigation link) for comment form is really important when your entry has a lot of comments. But there’s no point in having one when your comment form is just few pixel away after the entry.
This is how you can show the skip link if the comment reach n number of comments. Example below will make the skip link appear if 1) comment status is open 2) comment count is more and equal to 4.
- Open your Theme’s comments.php file.
<?php if ( have_comments() ) : ?>(or anywhere you find suitable) paste these lines:
<?php if ( comments_open() && ( 4 <= get_comments_number()) ) : ?> <a href="#respond">Skip to comment form</a> <?php endif; ?>
<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3> <?php if ( comments_open() && ( 4 <= get_comments_number()) ) : ?> <a href="#respond">Skip to comment form</a> <?php endif; ?>
Don’t forget to style the codes to match your layout.
- Finally, make sure that an element with ID attribute
respondis added or assigned. For example:
<h3 id="respond">Leave a Reply</h3>
Preferably right before the comment form.
Using named anchor (
<a name="respond" id="respond"><a/>) is outdated but still possible.