Use this for pagination
<?php
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$mostpopular_args=array(
'post_type' => 'post',
'orderby' => 'meta_value_num',
'meta_key' => 'view_count',
'paged' => $paged,
'posts_per_page' => '10',
);
$wp_query = new WP_Query($mostpopular_args);
while ($wp_query->have_posts()): $wp_query->the_post();
get_the_title();
endwhile;
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?>
Related Posts:
- Custom WP_Query order by post_meta and (author) user_meta
- How to paginate attachments in a secondary query as gallery?
- Add and in the header while looping over custom query in page template
- Paginated pages are showing correct content but pagination links are not
- Search – Ajax – Alter Query Parameters with Pagination
- Transient pagination not working properly
- WP_QUERY loop, offset in the arguments and the paginate_links – can these work together?
- How to output different posts per page?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination of a WP_Query Loop in a child-page page template
- paging in WP_Query on static page
- Get pagination working for custom loops within page templates
- WordPress Pagination changes my template
- Pretty urls for custom pagination
- Multisite pagination issue by multi query archive 404
- Pagination on template page for custom query redirecting to index.php
- Yoast primary category query modification
- Notice thrown when creating numeric pagination on custom query
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- I am officially missing something about transient posts
- Pagination of custom page with custom fields query
- Why pagination is not working with tax_query param?
- paginate_links method doesn’t show second page of my custom wp_query
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- Paginate nested query of child posts
- Custom pagination (Title, date and teaser)
- Using URL variables on a custom WP_Query
- Pagination in custom query in a category page
- Horizontally paginate through sets of blog posts?
- Pagination in WP query with transient API
- error with $query->have_posts()
- Search results stuck on page 1
- Pagination only showed when no category is set in wp_query
- Multiple WP_Query with pagination shows Page/2 content on the remaining pages
- Multiple queries and pagination
- When should you use WP_Query vs query_posts() vs get_posts()?
- Pagination when using wp_query?
- How can i retrieve default post per page value? from settings->reading. And total number of posts?
- Find out total number of pages in global query on archive page?
- order by numeric value for meta value
- Post_count only shows the number of results per page
- Wp get all the sub pages of the parent using wp query
- How to display page content in a page template?
- Multiple WP_Query loops with Pagination
- Pagination with custom SQL query
- Return only Count from a wp_query request?
- How to query for most viewed posts and show top 5
- WordPress Pagination Not Working – Always Showing First Pages Content
- WP_Query vs get_posts
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- How to remove_query_arg() for paginate_links()
- WP_Comment_Query pagination, delving into the unknown
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- Pagination on a WP_query not showing navigation links
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- How to paginate wordpress [gallery] shortcode?
- Pagination returns 404 after page 20
- Make a WP Query search match exactly the search term
- paginate_links() adds empty href to first page and previous link
- WP_Query: query posts by ids from array?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- paginate_links ignore my format
- Sort posts by category name and title
- Combining two wordpress queries with pagination is not working
- How to uniquely identify queries?
- What is the most efficient way of querying posts based on visits and date for current day?
- Query WooCommerce orders where meta data does not exist
- WP_Query for WooCommerce Products
- pre_get_posts with get_posts
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- WP_Query and Pagination on a Static front page
- next_posts_link not working for loop called with ajax
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- author.php with ACF and CPTs
- Query Custom Meta Value with Increment
- Why does pagination always break when used on any form of a home page?
- When should you use wp_reset_postdata vs wp_reset_query?
- Get posts by meta data OR title
- Pagination with 5 posts per page
- Identify which loop you are hooking into; primary or secondary?
- Pagination shows 404 after a certain number of pages
- Pagination custom query
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- How to make an activities stream mixing posts and comments?
- Duplicate Queries
- How to query for a week using key => value WP_Query argument notation?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Pagination not working for Custom search form & custom result template
- Pagination/infinite scroll with WP_Query and multiple loops
- Show only oldest post by author
- Order posts by tags count?
- How to adjust found_posts so that it accounts for offset and pagination
- Pagination broken when merging search results with additional WP_Query
- SQL query equivalent to WP User Query
- WP_query and pagination?
- pagenavi with merged wp_query [duplicate]