Skip to content

Instantly share code, notes, and snippets.

@tawanorg
Created February 26, 2015 04:51
Show Gist options
  • Save tawanorg/bc6d74b029025dc1bb68 to your computer and use it in GitHub Desktop.
Save tawanorg/bc6d74b029025dc1bb68 to your computer and use it in GitHub Desktop.
Easy Customize Wordpress Pagination
<?php
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
$limit = 1;
$offset = ( $pagenum - 1 ) * $limit;
$results = $wpdb->get_results("SELECT * FROM ex_contactus LIMIT $offset, $limit");
// DISPLAY DATA
$total = $wpdb->get_var("SELECT COUNT('id') FROM ex_contactus ");
$num_of_pages = ceil( $total / $limit );
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
'prev_text' => __( '&laquo;', 'aag' ),
'next_text' => __( '&raquo;', 'aag' ),
'total' => $num_of_pages,
'current' => $pagenum
) );
if ( $page_links ) {
echo $page_links;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment