Wordpress: Check if there are previous posts before displaying link

Posted by Chris Armstrong on Stack Overflow See other posts from Stack Overflow or by Chris Armstrong
Published on 2010-04-27T17:21:33Z Indexed on 2010/04/27 17:23 UTC
Read the original article Hit count: 311

Filed under:
|
|

I'm using the following code to display a 'previous posts' link on my Wordpress blog.

     <nav>
            <ul>
                <li><?php previous_posts_link('Newer Entries &raquo;') ?></li>
</ul
</nav>

Problem is, when there ARN'T any previous posts, while the link doesn't display, I still get

<nav>
            <ul>
                <li><</li>
</ul
</nav>

Printed out. Is there an if() statement I could wrap around it all so it checks if there are any previous posts, and only prints it out if there are?

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about navigation