Support » Fixing WordPress » Displaying pagination even when there’s no previous posts

  • I am helping with a website and the owner wants to display pagination even if there is no next or previous, non-clickable of course.

    For example, if you’re on the first page, she still wants “Previous” to display.

    Any ideas of how I could hack this? She’s using a twentysixteen child theme that is in development.

Viewing 1 replies (of 1 total)
  • This is from a devs perspective, I’m not sure if there’s a plugin out there that will do this but it seems niche.

    1) Copy the HTML of the previous post link either from source or html it yourself, etc.

    2) Get the current page, probably at the top of the page underneath get_header() or whatnot for organization.

    3) Conditionally show said HTML based on the paged variable:

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    
    if( $paged > 1 ) {
    	previous_posts_link( 'Previous' );
    } else {
    	echo '<a href="javascript:void(0);" style="pointer-events:none;">Previous</a>';
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Displaying pagination even when there’s no previous posts’ is closed to new replies.