WP-Paginate is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
WP-Paginate 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.
You can add custom CSS for your pagination links with the Custom CSS tab in WP-Paginate Settings.
Starting in version 1.1, WP-Paginate can also be used to paginate post comments!
Translations: https://plugins.svn.wordpress.org/wp-paginate/I18n (check the version number for the correct file)
Install and Activate
wp-paginate
folder and its contents into the wp-content/plugins/
directory of your WordPress installationImplement
You can now configure the location and appearance of pagination links through WP-Paginate Settings rather than edit your theme files. See the Configure section.
For posts pagination:
* Open the theme files where you’d like pagination to be used. Depending on your theme, this could be in a number of files, such as index.php
, archive.php
, categories.php
, search.php
, tag.php
, or the functions.php
file(s).The twentyeleven
theme places the pagination code in functions.php
in the twentyeleven_content_nav()
function.
Examples:
For the Twenty Seventeen
theme, in index.php
, replace:
the_posts_pagination( array( 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>', 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>', ) );
With:
if(function_exists('wp_paginate')): wp_paginate(); else : the_posts_pagination( array( 'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>', 'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>', ) ); endif;
For the Twenty Sixteen
theme, in index.php
, replace:
the_posts_pagination( array( 'prev_text' => __( 'Previous page', 'twentysixteen' ), 'next_text' => __( 'Next page', 'twentysixteen' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>', ) );
With:
if(function_exists('wp_paginate')): wp_paginate(); else : the_posts_pagination( array( 'prev_text' => __( 'Previous page', 'twentysixteen' ), 'next_text' => __( 'Next page', 'twentysixteen' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>', ) ); endif;
For the Twenty Fifteen
theme, in index.php
, replace:
the_posts_pagination( array( 'prev_text' => __( 'Previous page', 'twentyfifteen' ), 'next_text' => __( 'Next page', 'twentyfifteen' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>', ) );
With:
if(function_exists('wp_paginate')): wp_paginate(); else : the_posts_pagination( array( 'prev_text' => __( 'Previous page', 'twentyfifteen' ), 'next_text' => __( 'Next page', 'twentyfifteen' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>', ) ); endif;
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('wp_paginate_comments')) { wp_paginate_comments(); } ?>
Configure
1) Configure the WP-Paginate settings, if necessary, from the WP-Paginate option in the Settings menu
2) The styles can be changed with the following methods:
wp-paginate.css
file in your theme’s directory and place your custom CSS therestyles.css
wp-paginate.css
file in the wp-paginate plugin directoryNote: The first two options will ensure that WP-Paginate updates will not overwrite your custom styles.
Upgrading
To 1.1.1+:
Before Markup
to <div class="navigation">
wp-paginate.css
, change .wp-paginate ol
to .wp-paginate
The wp_paginate()
and wp_paginate_comments()
functions each takes one optional argument, 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:
Example (also applies to wp_paginate_comments()
):
<?php if(function_exists('wp_paginate')) { wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous'); } ?>
When calling wp_paginate_comments()
, WP-Paginate adds an extra class to the ol
element, wp-paginate-comments
.
<
nav> tag to the list of allowed tags for pagination markup
= 1.3.4=
* Tested with WordPress 4.7.1
wp-paginate
and wp-paginate-comments
class names on the ol
elementbefore
option from <div class="wp-paginate">
to <div class="navigation">
.wp-paginate-comments
styles to wp-paginate.css
wp-paginate.css
wp_paginate_comments()
function for pagination of post comments