Search
 
SCRIPT & CODE EXAMPLE
 

PHP

make pagination wordpress admin panel

// page parameter
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
// Find total number of records

$limit = 10; // number of rows in page
$offset = ( $pagenum - 1 ) * $limit;
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM {$wpdb->prefix}table_name" );
$num_of_pages = ceil( $total / $limit );

// Give Limit
$entries = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}table_name LIMIT $offset, $limit" );


// add this code where you want to add pagintaion
$page_links = paginate_links( array(
    'base' => add_query_arg( 'pagenum', '%#%' ),
    'format' => '',
    'prev_text' => __( '«', 'text-domain' ),
    'next_text' => __( '»', 'text-domain' ),
    'total' => $num_of_pages,
    'current' => $pagenum
) );

if ( $page_links ) {
    echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>';
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to json_encode an array in php unexpected identifier 
Php :: how to delete a file in laravel 
Php :: laravel create migration view 
Php :: php mysql error 
Php :: php tags 
Php :: laravel send post request from controller 
Php :: laravel when 
Php :: Git delete single branch 
Php :: php artisan preset react 
Php :: laravel login by id 
Php :: laravel whereraw 
Php :: get type of variable php 
Php :: php Call to undefined function mb_convert_case() 
Php :: curl php post 
Php :: check string in php 
Php :: validate executable path vscode 
Php :: how to get all roles in wordpress 
Php :: request old laravel form select 
Php :: create new laravel project cmd 
Php :: centos :Install or enable PHP gd extension. 
Php :: minuscule string php 
Php :: add column in existing table in laravel 
Php :: laravel meta csrf 
Php :: How to get only year, month and day from timestamp in Laravel 
Php :: Laravel Session using Global Session php function 
Php :: increase upload limit in phpmyadmin docker 
Php :: group array php by key 
Php :: twig ternary 
Php :: WP_DEBUG enable 
Php :: Woocommerce Display field value on the admin order edit page [Custom Field Display 2] 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =