How to wrap paginate_links() with HTML tags

In order to follow the CSS styles of WooCommerce, you may need to wrap the paginate_links() function with HTML tags (such as list tags).

Wrapping paginate_links() with HTML tags

If you’re looking to follow the WooCommerce CSS styles for paginated links, you should use the below code (including the classes used) in order to achieve this.

$pages = paginate_links( array( 'type' => 'array' ) );
     if( $pages ) {
     echo '<nav class="woocommerce-pagination"><ul class="page-numbers">';
     foreach ( $pages as $page ) {
          echo "<li>$page</li>";
     }
     echo '</ul></nav>';
}

Note: The type parameter within the paginate_links() arguments is important to maintain, as this outputs the results as an array for you to loop through them. Furthermore, if you’re adding this to a non-WooCommerce page, you should include the woocommerce class within your body tag.