I'm using the following code for comments pagination (based on 2014 theme)
<?php if( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?> <ul class="pager"> <li class="previous"> <?php previous_comments_link( __( '← Older Comments', '' ) ); ?> </li> <li class="next"> <?php next_comments_link( __( 'Newer Comments →', '' ) ); ?> </li> </ul> <?php endif; ?>
I noticed that if I'm on the first page, the
.previous list item is still in the DOM. It's empty but still there.
<li class="previous"> </li>
I tried to find a proper function in the Functions Reference, but found nothing.
What I'm trying to do is to check conditionally if
next_comments_link() should be displayed. If not, then do not display the list item.
I don't know if this is a good idea (semantic) to remove whole list item.