How to check if post has previous_comments_link() and next_comments_link()
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( __( 'larr; Older Comments', '' ) ); ?
/li
li class="next"
?php next_comments_link( __( 'Newer Comments rarr;', '' ) ); ?
/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 previous_comments_link()
and 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.
Topic paginate-comments-links comments Wordpress
Category Web