Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add pagination to wordpress

<?php
     echo paginate_links( array(
        'mid_size'  => 3,
        'prev_text' => __( '&laquo; Prev', 'textdomain' ),
        'next_text' => __( 'Next &raquo;', 'textdomain' ),
      ) );
 ?>
Comment

custom pagination in wordpress

<?php
function custom_pagination($numpages = '', $pagerange = '', $paged='') {
    if (empty($pagerange)) {
        $pagerange = 2;
    }
    global $paged;
    if (empty($paged)) { 
        $paged = 1;
    }
    if ($numpages == '') {
        global $wp_query;
        $numpages = $wp_query->max_num_pages;
        if(!$numpages) {
                $numpages = 1;
        }
    }
    $pagination_args = array(
        'base'            => get_pagenum_link(1) . '%_%',
        'format'          => 'page/%#%',
        'total'           => $numpages,
        'current'         => $paged,
        'show_all'        => False,
        'end_size'        => 1,
        'mid_size'        => $pagerange,
        'prev_next'       => True,
        'prev_text'       => __('&laquo; Previous'),
        'next_text'       => __('Next &raquo;'),
        'type'            => 'plain',
        'add_args'        => false,
        'add_fragment'    => ''
    );
    $paginate_links = paginate_links($pagination_args);
    if ($paginate_links) {
        echo "<div class='listing-pagination'>";
        echo "<span class='pagination-nav'>".$paginate_links."</span>";
        echo "</div><div class='divider div-transparent'></div>";
    }
};
custom_pagination($query->max_num_pages,"",$paged);
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php convert to lowercase 
Php :: carbon difference between two dates 
Php :: Laravel Validation error message in blade or view 
Php :: twig filter line break 
Php :: if object or array in php 
Php :: laravel custom attributes 
Php :: create view from route laravel 
Php :: laravel new date 
Php :: laravel check if model relation exists 
Php :: date and time in php 
Php :: add blade in blade laravel 
Php :: laravel in array blade 
Php :: laravel clear page cache 
Php :: In PackageManifest.php line 122: 
Php :: woocommerce get post meta 
Php :: install laravel 
Php :: convert byte to megabyte php 
Php :: mysqli last index php 
Php :: php mkdir with 777 permission 
Php :: the posts pagination 
Php :: mpdf output 
Php :: auth.php Class "AppUser" not found 
Php :: random 6 digit number php 
Php :: get blog page url in wordpress 
Php :: laravel get data from this year 
Php :: laravel get all session data 
Php :: laravel migrate refresh specific migration 
Php :: php var_export to string 
Php :: format date in php 
Php :: wordpress loop over posts but exclude current post 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =