loop_pagination()
The loop_pagination()
function requires that your theme be using the loop-pagination
extension of Hybrid Core. It uses the WordPress function paginate_links()
to display paginated links (i.e., page numbers) on blog, archive, and search pages as opposed to WordPress’ default previous/next links.
Parameters
loop_pagination( $args = array() )
This function takes in a single parameter of $args
, which is an array of arguments to define how the pagination should be displayed.
There are only three arguments specific to the loop_pagination()
function. If you’re a developer and want more in-depth information on the arguments you can pass into paginate_links()
, please see the Codex documentation on them.
before
- (string) HTML to display before the output of the links.
after
- (string) HTML to display after the output of the links.
echo
- (bool) Whether to display the pagination links or return them.
Default arguments
$defaults = array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
'total' => $max_num_pages,
'current' => $current,
'prev_next' => true,
'prev_text' => __( '« Previous' ), // This is the WordPress default.
'next_text' => __( 'Next »' ), // This is the WordPress default.
'show_all' => false,
'end_size' => 1,
'mid_size' => 1,
'add_fragment' => '',
'type' => 'plain',
'before' => '<div class="pagination loop-pagination">', // Begin loop_pagination() arguments.
'after' => '</div>',
'echo' => true,
);
Usage
This function should only be used on multi-post pages (e.g., archives, blog, search).
You should check that the theme supports loop-pagination
before using the function like so:
if ( current_theme_supports( 'loop-pagination' ) ) loop_pagination();
The following example changes the previous and next text:
loop_pagination( array( 'prev' => 'Previous Posts', 'next' => 'Next Posts' ) );