pre_get_posts did the trick (thanks Pieter and cybmeta!
Here’s the solution:
function hwl_home_pagesize( $query ) {
if ( is_post_type_archive( 'motivation' ) ) {
$query->set( 'posts_per_page', 9 );
return;
}
if ( is_post_type_archive( 'blog' ) ) {
$query->set( 'posts_per_page', 14 );
return;
}
}
add_action( 'pre_get_posts', 'hwl_home_pagesize', 1 );
That’s it!
Related 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?
- Post_count only shows the number of results per page
- Multiple WP_Query loops with Pagination
- Pagination with custom SQL query
- WordPress Pagination Not Working – Always Showing First Pages Content
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- 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
- paginate_links() adds empty href to first page and previous link
- paginate_links ignore my format
- Combining two wordpress queries with pagination is not working
- Custom WP_Query order by post_meta and (author) user_meta
- How to paginate attachments in a secondary query as gallery?
- 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?
- Why does pagination always break when used on any form of a home page?
- Pagination with 5 posts per page
- Pagination shows 404 after a certain number of pages
- Pagination custom query
- Pagination not working for Custom search form & custom result template
- Paging works correctly on local version, but not live?
- Pagination not working in custom loop WP_Query
- pagination functions are not working
- Showing the correct number of posts_per_page when avoiding the use of post__not_in
- WordPress pagination not returning posts on second page
- Paginated Post List on Front Page
- Paginate nested query of child posts
- How to set up pagination for a custom loop on a global template (author.php, tag.php, archive.php?)
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Pagination in WP_Query?
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Pagination returns 404 after page 20
- 3 wp_query on one page with pagination for last query
- Custom pagination (Title, date and teaser)
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- custom query – offset to pagination
- Archive – Show Page Month Headers
- previous_posts_link not working in WordPress pagination
- Query post Pagination Problem
- Pagination not working with WP_QUERY
- Add pagination to table generated by wp_query
- Pagination for custom query throws 404 errors on last pages [duplicate]
- WP_Query with meta_value_num and meta_query not paged correctly
- Pagination is not working on custom query inside a custom home page template
- Pagination in custom query in a category page
- Horizontally paginate through sets of blog posts?
- Pagination not working in some author pages
- Pagination error WordPress multiple loop
- Pagination with WP_Query not working
- How to add archives (with pagination) to page template?
- No content found on page 2 of pagination with 1 post per page
- Comments orderby comment date not working
- Switched from query_posts to wp_query, pagination no longer working
- What is wrong with this pagination code?
- wp_query pagination links producing 404
- Pagination With Custom WP Query not functioning
- Can’t get pagination to work with this WP_Query loop
- Pagination in custom loop [duplicate]
- Ordering Custom WP_Query loop by meta key value with pagination
- Query specific number of posts for each post type in specific order
- Loop being strainge
- Why won’t my paged wp_query work? [duplicate]
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- WP_Query breaks pagination
- Pagination in custom query not working [duplicate]
- Pagination doesn’t work for home page custom post type query
- Loop issues when creating custom query for media uploader
- Query multiple taxonomies with pagination
- Pagination in WP query with transient API
- paginate_links() on page (shortcode output)
- paginate_links() with Custom Taxonomy
- Multiple loops on index page with sticky post and pagination
- Pagination problem with multiple loops on the same page
- WordPress Post Looping? [duplicate]
- Pagination not working in secondary query
- WP Paginate not working properly
- Paginate wp_query while utilizing post__not_in
- Get next post when using pagination with WP_Query?
- Duplicate posts showing up in loop using infinite scroll
- Pagination showing same posts despite changing page
- error with $query->have_posts()
- Pagination with Custom Post Type not working on index.php: I get a 404
- Pagination on custom post type not working
- Pagenavi with archive page
- Show number of posts AND number on current page (cannot make it work)
- Search results stuck on page 1
- Limit paginated result set to a maximum number of posts
- Pagination only showed when no category is set in wp_query
- taxonomy-{term}.php terms pagination returning 404 after a certain page
- Multiple WP_Query with pagination shows Page/2 content on the remaining pages
- Multiple queries and pagination