PHP code example of themehybrid / hybrid-pagination

1. Go to this page and download the library: Download themehybrid/hybrid-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/ */

    

themehybrid / hybrid-pagination example snippets


$app->register( \Hybrid\Pagination\PaginationServiceProvider::class );

use function Hybrid\Pagination\display;
use function Hybrid\Pagination\render;
use function Hybrid\Pagination\pagination;

// Echoes the pagination markup.
display( 'posts' );

// Returns the pagination markup as a string.
$html = render( 'posts' );

// Returns the underlying Pagination object, letting you inspect it before output.
pagination( 'posts' )->make()->display();

use Hybrid\Pagination\Contracts\Pagination;

$pagination = app( Pagination::class, [
    'context' => 'posts',
    'args'    => [],
] );

$pagination->make()->display();

// Main loop pagination.
display( 'posts' );

// Singular, multi-page post pagination (`<!--nextpage-->`).
display( 'post' ); // `singular` is also accepted as an alias for `post`.

// Comment pagination.
display( 'comments' );

display( 'posts', [
    'mid_size'           => 2,
    'end_size'           => 1,
    'prev_text'          => __( 'Previous', 'my-theme' ),
    'next_text'          => __( 'Next', 'my-theme' ),
    'screen_reader_text' => __( 'Posts navigation', 'my-theme' ),
] );

// Filter default args for a given context, before user args are merged in.
add_filter( 'hybrid/pagination/posts/defaults', function ( $defaults ) {
    return $defaults;
} );

// Filter the final, merged args for a given context.
add_filter( 'hybrid/pagination/posts/args', function ( $args ) {
    return $args;
} );

// Filter the final rendered markup for a given context.
add_filter( 'hybrid/pagination/posts', function ( $html, $args ) {
    return $html;
}, 10, 2 );

// Filter each built page link URL (also runs through core's `paginate_links` filter).
add_filter( 'paginate_links', function ( $link ) {
    return $link;
} );