If you wanted to have a greyed out link, you could swap out posts_nav_link
for something like this:
<?php if ( ! get_previous_posts_link() ) : ?>
<div class="inactive post-link post-link__previous">« Previous Posts</div>
<?php else : ?>
<div class="post-link post-link__previous"><?php previous_posts_link(); ?></span>
<?php endif; ?>
And just set the inactive
class in your CSS to be greyed out. You then would obviously repeat the same with the get_next_posts_link()
and next_posts_link()
functions.
If you wanted to loop back, you could try something like this, if your homepage is setup as your posts page.
<?php if ( ! get_next_posts_link() ) : ?>
<div class="inactive post-link post-link__next">
<a href="https://wordpress.stackexchange.com/questions/259661/<?php echo home_url(); ?>">Next Posts</a>
</div>
<?php else : ?>
<div class="post-link post-link__next"><?php next_posts_link(); ?></span>
<?php endif; ?>
If your posts page is setup as a static page, you can grab the url for it like this echo get_permalink( get_option('page_for_posts' ) );
.
Hope this helps.