WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When on the first page of blog wordpress shows only "older posts" link because there are no newer posts, but i would like to show also the "newer posts" link but style it as inactive.

i need to do the same thing with page navigation and with single posts navigation.


share|improve this question
what is the code of these links at the moment? – Michael Dec 17 '11 at 14:53
currently the code is: <?php if (show_posts_nav()) : ?> <nav class="page_navi"> <ul> <li class="newer_link"><?php previous_posts_link('Newer posts'); ?></li> <li class="older_link"><?php next_posts_link('Older posts'); ?></li> </ul> </nav> <?php endif; ?> – Mikk Olli Dec 17 '11 at 18:08

If you check the code for previous_posts_link function in link-template.php file i.e.

function previous_posts_link( $label = null ) {
   echo get_previous_posts_link( $label );
// get_previous_posts_link
function get_previous_posts_link( $label = null ) {
  global $paged;
  if ( null === $label )
     $label = __( '&laquo; Previous Page' );
        if ( !is_single() && $paged > 1 ) {
           $attr = apply_filters( 'previous_posts_link_attributes', '' );
           return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label ) .'</a>';

you can clearly see that the condition is set for page > 1, means on page one it will not show the link. For this you can use PageNavi plugin or you can dig into the code to override the default behavior. One more suggestion, don't alter the core files as you will loose this functionality when you will upgrade WP.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.