What you are doing here is on the Bad Ideas list. While you can replace the query in template that tends to break things, especially pagination.
In simplified form let’s say you have 10 testimonials and your WP settings are 5 posts per page:
- your template thinks there are 10 / 2 = 5 pages worth of testimonials
- but WordPress thinks there are only 10 / 5 = 2 pages!
So when URL instructs WP to show page 3… WP thinks there is nothing there. And this is just the one of obvious ways in which it breaks.
For any modificaiton of main loops you need to be using filter like pre_get_posts
and do it before template is even reached.
Related Posts:
- Pagination not working with custom loop
- Have different number of posts on first page
- wp_pagenavi() with custom wp_query()?
- Custom Post Type Pagination Not Working On Archive Page
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Archive page…limiting posts per page
- Pagination go to first page if i’m on last post
- Posts in Multiple Columns and Rows with one single loop
- Newer/Older posts links display same posts on every page
- Fix custom query pagination without changing site-wide posts-per-page settings
- Pagination with custom post types results in 404 issues
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Paging doesn’t work?
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- pagination not working for category.php (custom post types in categories)
- Pagination Error : Duplicate argument being outputted
- Custom Post Type, Pagination and 404s?
- Custom post type pagination error
- Custom archive page for custom taxonomy and pagination issue
- Custom post type paging return home page
- Pagination not working in custom post type. Help
- Pagination Not Working When Used With WP_Query() `offset` Property
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- next_posts_link() always generates second page link on custom post type
- 2 custom posts types, in their own columns, one pagination for both
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- Pagination on custom post types
- Pagination in custom post type page template
- Custom post type archive pagination with HTML5Blank theme?
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Pagination not working with custom loop
- Fourth page of custom post type archive page does not exist
- WPNavi pagination links not working on custom pages
- Pre get posts for single post
- Pagination not working with custom category template
- Custom Post Type pagination – normal solutions aren’t helping
- Custom Post Type Archives by Date (stored as meta value) WP3.1
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- How to display the rest of categories on Portfolio filterable
- Paginate Custom Post Type Page
- Get_post_meta() won’t return value
- Query Custom Post by Category
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Pagination Issue: Custom Post Type In Index
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Custom post type archive not regarding ‘posts_per_page’ => -1
- get_template_part for custom post type content not working
- Creating Accordians in WordPress Theme
- Display different content on homepage depending on post type
- Pagination on a custom post type loop
- WP_Query orderby modified to include custom meta changes
- get_attached_media() on author page not working
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- What to and how to proceed with CPT to make DB small and efficient?
- How can I group posts by months and years?
- Can’t use pagination with custom taxonomy
- Custom ordering of CPT items not matching with the ordering of its pagination
- How to list custom post types on a custom post type page?
- Display post from custom post type
- WordPress giving a 404 page when passing a year argument different than the current year
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Drop down list with posts within the “add new” page
- How to show custom post type on homepage and in categories
- using the loop in custom meta is messing up ‘add new’ post type
- How can I loop at a Specific Taxonomy from a custom post type?
- Update query based on CPT / Post Type, show all sorted by date
- WordPress next post by ajax call on button click
- How to avoid duplicate posts queried from custom meta?
- pagination problem listing custom post types of taxonomy in wordpress
- Why do my custom post type show up in all pages?
- Looping to organize and display custom posts by category using PHP and WordPress
- My post loop needs to have 8 different post templates
- Mix Facebook and Twitter feed into custom posts
- Pagination with a custom post type
- Infinite scroll doesnt work
- Pagination URL in Custom Content Type
- Excluding category from loop not working
- Tricky Custom post loop
- Custom taxonomy page template
- Display posts from category in page
- Custom post type blog pagination conflict
- Custom post type pagination, single page issue
- Multiple Queries and Loops within CPT Archive
- Query Custom Post Type by Tag
- Loops running into each other
- Display by tag from different post types
- Loop doesn’t work in single-product.php page but works at normal page
- Two pagination in one page without AJAX