[php]
$customPagHTML = “”;
$query = “SELECT * FROM inthenews where by_jrp = ‘yes’ ORDER BY `date` desc”;
$total_query = “SELECT COUNT(1) FROM (${query}) AS combined_table”;
$total = $wpdb->get_var( $total_query );
$items_per_page = 4;
$page = isset( $_GET[‘cpage’] ) ? abs( (int) $_GET[‘cpage’] ) : 1;
$offset = ( $page * $items_per_page ) – $items_per_page;
$result = $wpdb->get_results( $query . ” ORDER BY field DESC LIMIT ${offset}, ${items_per_page}” );
$totalPage = ceil($total / $items_per_page);
if($totalPage > 1){
$customPagHTML = ‘

Page ‘.$page.’ of ‘.$totalPage.’‘.paginate_links( array(
‘base’ => add_query_arg( ‘cpage’, ‘%#%’ ),
‘format’ => ”,
‘prev_text’ => __(‘«’),
‘next_text’ => __(‘»’),
‘total’ => $totalPage,
‘current’ => $page
)).’

‘;
}
echo $customPagHTML;
[/php]