Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Thanks

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.