I am new with php and word press. I have a question that I am using a `sql query` in my `posts` to get data from my `data base`. Now the problem is that I have huge data on my `post` and I do not have idea how to apply `pagination` on the data which has been fetched using the `SQL query`. Here is the code which I am using in my `post`. <?php global $wpdb; // QUERY HERE TO COUNT TOTAL RECORDS FOR PAGINATION $total = $wpdb->get_var("SELECT COUNT(hadith_no, content) FROM muslim"); $post_per_page = 10; $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; $offset = ( $page * $post_per_page ) - $post_per_page; // QUERY HERE TO GET OUR RESULTS $results = $wpdb->get_results("SELECT hadith_no, content FROM muslim"); // PHP FOR EACH LOOP HERE TO DISPLAY OUR RESULTS foreach($results as $row) { echo $row->hadith_no." ".$row->content."<br>"; } // END OUR FOR EACH LOOP ?> // PAGINATION HERE IN NICE BOOTSTRAP STYLES <?php echo '<div class="pagination">'; echo paginate_links( array( 'base' => add_query_arg( 'cpage', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($total / $post_per_page), 'current' => $page, 'type' => 'list' )); echo '</div>'; ?> I have searched around but came up with some `plugins` but those plugins do not work with the `SQL queries`. Any one who can help me using `pagination` on my `post` or edit this code so that I can have `pagination`. Thank you.