From ecda11ac10f7f409de30f063ad0bee77d78fca03 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Sat, 14 Dec 2019 12:00:39 +0100 Subject: [PATCH] Add support for non-archive pages By relaxing the exit condition understrap_pagination() may be used in custom loops. See #1054 for an how to example. --- inc/pagination.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/pagination.php b/inc/pagination.php index 6db6170..898dd98 100644 --- a/inc/pagination.php +++ b/inc/pagination.php @@ -12,7 +12,7 @@ if ( ! function_exists( 'understrap_pagination' ) ) { function understrap_pagination( $args = array(), $class = 'pagination' ) { - if ( $GLOBALS['wp_query']->max_num_pages <= 1 ) { + if ( ! isset( $args['total'] ) && $GLOBALS['wp_query']->max_num_pages <= 1 ) { return; } @@ -30,6 +30,9 @@ if ( ! function_exists( 'understrap_pagination' ) ) { ); $links = paginate_links( $args ); + if ( ! $links ) { + return; + } ?>