TW Pagination is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
TW Pagination is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
In addition to increasing the user experience for your visitors, it has also been widely reported that pagination increases the SEO of your site by providing more links to your content.
TW Pagination can also be used to paginate post comments!
Install and Activate
tw-pagination
zip filetw-pagination
folder and its contents into the wp-content/plugins/
directory of your WordPress installationImplement
For posts pagination:
1) Open the theme files where you’d like pagination to be used. Usually this is the loop.php
file. For older version of WordPress, you may need to update the index.php
, archive.php
and search.php
files.
2) Replace your existing previous_posts_link()
and next_posts_link()
code block with the following:
<?php if(function_exists('tw_pagination')) tw_pagination(); ?>
For comments pagination:
1) Open the theme file(s) where you’d like comments pagination to be used. Usually this is the comments.php
file.
2) Replace your existing previous_comments_link()
and next_comments_link()
code block with the following:
<?php if(function_exists('tw_pagination_comments')) tw_pagination_comments(); ?>
Configure
1) Configure the TW Pagination settings, if necessary, from the TW Pagination option in the Settings menu
2) The styles can be changed with the following methods:
tw-pagination.css
file in your theme’s directory and place your custom CSS therestyles.css
tw-pagination.css
file in the tw-pagination plugin directoryNote: The first two options will ensure that TW Pagination updates will not overwrite your custom styles.
The tw_pagination()
and tw_pagination_comments()
functions each takes two optional arguments.
Second argument is in query string format, which allows you to override the global settings. The available options are:
You can even control the current page and number of pages with:
Examples (also applies to tw_pagination_comments()
):
1) To paginate custom WP_Query:
<?php $the_query = new WP_Query( $args ); while($the_query->have_posts()) : $the_query->the_post(); // your code endwhile; if(function_exists('tw_pagination')) tw_pagination($the_query, 'range=4&anchor=2&nextpage=Next&previouspage=Previous'); ?>
2) To paginate default WP_Query with custom settings
<?php if(function_exists('tw_pagination')) tw_pagination('global', 'range=4&anchor=2&nextpage=Next&previouspage=Previous'); ?>
3) To paginate default WP_Query
<?php if(function_exists('tw_pagination')) tw_pagination(); ?>
When calling tw_pagination_comments()
, TW Pagination adds an extra class to the ol
element, tw-pagination-comments
.
This allows you to use the .tw-pagination-comments
styles, already in tw-pagination.css
, to override the default styles.