Created
February 26, 2015 04:51
-
-
Save tawanorg/bc6d74b029025dc1bb68 to your computer and use it in GitHub Desktop.
Easy Customize Wordpress Pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' => __( '«', 'aag' ), | |
'next_text' => __( '»', '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