Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Pagination #318

Closed
zslabs opened this issue Mar 1, 2012 · 2 comments
Closed

Improved Pagination #318

zslabs opened this issue Mar 1, 2012 · 2 comments
Labels

Comments

@zslabs
Copy link
Contributor

zslabs commented Mar 1, 2012

Hey Ben,

The default post navigation uses the standard, boring Older Posts or Newer Posts

<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ($wp_query->max_num_pages > 1) { ?>
  <nav id="post-nav" class="pager">
    <div class="previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
    <div class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
  </nav>
<?php } ?>

Referencing http://wp.tutsplus.com/tutorials/wordpress-pagination-a-primer/ I think a much more usable alternative would be the following:

<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php
    global $wp_query;  
    $total_pages = $wp_query->max_num_pages;  
    if ($total_pages > 1){  
        $current_page = max(1, get_query_var('paged'));  
        echo '<div class="page_nav">';  
        echo paginate_links(array(  
            'base' => get_pagenum_link(1) . '%_%',  
            'format' => 'page/%#%',  
            'current' => $current_page,  
            'total' => $total_pages,  
            'prev_text' => 'Prev',  
            'next_text' => 'Next'  
        ));  
        echo '</div>';  
    } 
?>

As it states in the article, this will put both Prev, Next and page numbers as well.

I know I keep throwing these code changes at you - I'll sit down and learn how to properly do these through GitHub soon :)

@retlehs
Copy link
Member

retlehs commented Apr 2, 2012

we should use the bootstrap pagination. i've got it in use on http://benword.com utilizing some slightly modified code from @eddiemachado's bones

@retlehs
Copy link
Member

retlehs commented Jul 21, 2012

gonna close this for now.. i'd recommend using http://wordpress.org/extend/plugins/wp-pagenavi/

@retlehs retlehs closed this as completed Jul 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants