Max Pages in Pagination
-
When pagination is set to true, and we are limiting the number of posts retrieved by 6, how do we figure out the total number of pages based on the total number of posts and the limit we are setting?
The following code shows how to do the above question in a typical WordPress query:
$args = array( 'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', 'posts' => json_encode($events->query_vars), 'current_page' => $events->query_vars['paged'] ? $events->query_vars['paged'] : 1, 'max_page' => $events->max_num_pages )
the following code is my args array passed to the get method on the EM_Events class
$posts = EM_Events::get(array( 'scope' => 'future', 'limit' => 6, 'pagination' => 1, 'category' => $_POST['event-category'], ));
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Max Pages in Pagination’ is closed to new replies.