PHP code example of larawelp / pagination

1. Go to this page and download the library: Download larawelp/pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larawelp / pagination example snippets


global $wp_query;

// The total number of items
$total       = (int)$wp_query->found_posts;

// The number of items are going to be displayed per page.
$perPage     = (int)$wp_query->query_vars['posts_per_page'];

// The current page number.
$currentPage = (int)$wp_query->query_vars['paged'];

// additional options
$options     = ['urlStyle' => 'pretty'];


$paginator   = new Paginator($total, $perPage, $currentPage, $options);
    
echo $paginator->toHtml();

$paginator = new Paginator($total, $perPage, $currentPage, ['view'=> '/www/var/example.com/pagination.php']);