Don’t create a new query. You can use pre_get_posts for this type of works.
Example : If you want to add books and movies custom post type to home page main loop,
function books_movies_cpt_in_home($query) {
if ($query->is_home() && $query->is_main_query()) {
$query->set('post_type', array('books','movies'));
}
}
add_action('pre_get_posts', 'books_movies_cpt_in_home');
Related Posts:
- Custom post type pagination 404 fix?
- Pagination throws 404 error on custom taxonomy archive pages
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Archive page…limiting posts per page
- Secondary loop pagination on custom post type single post gets redirected to first page
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- paginate function in archive for custom-post-type
- Custom Post Type, Two categories, Two columns with Pagination
- Pagination gives 404 error
- Creating a simple pagination for custom post type templates
- Pagination not working
- Pagination Custom post type
- Custom Post Type Pagination & duplicate posts
- Unable to get paginate_links working with a custom query [duplicate]
- Custom post type, permalinks & pagination, going wrong
- Repeating posts when paginating random posts
- Hard code the nextpage tag into my theme?
- Pagination for custom php code
- Pagination for Custom Taxonomy Page [duplicate]
- Pagination on with query_posts in custom post type template
- Paging doesn’t work?
- Help with Elementor Pagination CPT archive 404 problem
- Custom taxonomy rewrite give pagination 404
- Next and Previous Posts of Same Parent
- How to handle paged param in post and custom-post-type?
- Next Post links not working in custom post type shortcode
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- pagination not working for category.php (custom post types in categories)
- Custom post type pagination 404
- Pagination broken by naming conflict between CPT and Page
- Pagination Error : Duplicate argument being outputted
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Trouble with pagination
- previous_post_link in same taxonomy in custom post type
- How to do admin CRUD & Pagination
- Pagination hitting 404 page on /page/4
- Using Pagination for Custom Post Type and keeps returning 404
- Pagination for search results of custom post type [duplicate]
- Pagination of custom post type leads to 404 error
- All blog posts are not showing up
- Custom post pagination trouble
- Pagination on a page
- Single parent post lists child posts with pagination
- Using custom post type as front home page pagination not working
- Custom Post Type, Pagination and 404s?
- 2 custom post type paging in 1 custom taxonomy
- Problem with custom loop navigation inside the blog page
- pagination for custom post type archive page
- custom taxonomy pagination 404 error
- Sticky posts limit query and pagination for a custom post type
- Pagination in custom post type archive.php not working
- Pagination Not Working When Used With WP_Query() `offset` Property
- Custom Post Type Pagination getting 404 error
- Numeric pagination custom post type
- Problems in paginate_links with custom query loop and MB-Relationships
- Make pagination work as a carousel (custom query)
- User Archive page for Custom Post Type – Pagination Issue
- Custom post pagination not working
- CPT/Taxonomy/Postname permalink structure makes pagination break
- I want to create pagination for my custom post type archive that i am displaying with loop
- How to get a custom post type archive paged when using a custom field for post sorting?
- Pagination in wp-admin for CPT
- 404 error next-page [2] PageNavi custom type taxonomy
- Add pagination to custom page
- yet another: custom post type with pagination not working in WordPress
- Pods pagination erases my sub menu
- Get Non-Paginated Index of Post in Paginated Query
- Custom post type with Filter and Page Nav
- Pagination fault in custom post type archive page [duplicate]
- Pagination custom post types outside loop
- Paginating custom query on category template
- Custom post type blog pagination conflict
- Custom post type pagination, single page issue
- Pagination always adding “Next” link when results come from Custom Post Type WP_query
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- Using pagination with specific custom post type [duplicate]
- how to limit query_post to first page?
- Pagination not working with custom loop
- Pagination not working with custom loop
- Archive Page Pagination not working
- Classic Custom Post Types and WP-PageNavi
- List of filtered Events is breaking paging?
- Pagination not working with custom loop
- Pagination not working on homepage
- send user to first page of results when reposting to page?
- How do I paginate a custom post type listing on a custom template page?
- Fourth page of custom post type archive page does not exist
- Pagination broke after updateto WordPress 3.4 [duplicate]
- WordPress pagination URL
- WordPress getting problem with pagination [duplicate]
- What Is My Fault With This WP_QUERY ? [ Pagination Problem ]
- Unable to display paging navigation with a custom post type loop
- Pagination not working only on Archive-Name.php using new WP_Query
- Pagination not working on custom post type archive
- Archive pagination – second page shows exactly the same posts
- Two pagination in one page without AJAX
- “Page not found” while on page 2 from pagination menu
- Issues with Ajax Pagination and Filtering
- Custom post type pagination not working in index.php file