I think next_posts_link() is using the global $wp_query to determine pagination, but you’ve created a new query here. Try passing max_num_pages from your $loop query to it:
next_posts_link( '<span class="nextpost">Next</span>', $loop->max_num_pages );
Related Posts:
- pagination not working for category.php (custom post types in categories)
- Pagination Not Working When Used With WP_Query() `offset` Property
- Fourth page of custom post type archive page does not exist
- Query Multiple Post Types and Paginate Newly Created List
- How do you get the count of posts in an archive page?
- How to use a custom post type as front page?
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Display several random posts, but make sure a condition is met
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Pagination Doesn’t Work
- Numeric pagination custom post type
- Posts in Multiple Columns and Rows with one single loop
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Fix custom query pagination without changing site-wide posts-per-page settings
- Query Custom Post by Category
- Pagination not working
- Pagination Issue: Custom Post Type In Index
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Lists Posts from CPT that match the Title of the Page
- Remove duplicated values from a loop
- Unable to get paginate_links working with a custom query [duplicate]
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Can I create a loop with multiple post types and specify different $args for each post type?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Pagination on a custom post type loop
- WP_Query orderby modified to include custom meta changes
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Previous/Next Link by Meta Value in CPT
- Pagination for Custom Taxonomy Page [duplicate]
- Custom loop with multiple taxonomy queries
- Paging doesn’t work?
- Custom taxonomy rewrite give pagination 404
- What’s the WP way to load remaining custom posts?
- How do you paginate a query grouped by month?
- Problem: wp_query outputs all images on site
- Custom Post Types strange pagination problem
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- WP Query post__in not returning correct results
- How can I group posts by months and years?
- Pagination Error : Duplicate argument being outputted
- Custon Content within WordPress Loop
- Custom WP_Query always respond with 200 status even when no entry
- Trouble with pagination
- Pagination 404 on Index with custom query
- get_pagination not working on a custom post type query (using WP_Query)
- WP_Query with custom post type ID
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Trying to add a class to post links
- postsperpage value not being applied
- Display the current post in browser as the first post in a loop (for a slideshow)
- Custom Post Type Archive Pagination
- Display post from custom post type
- List all Custom Post Type posts excluding certain Taxnomy term
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Single parent post lists child posts with pagination
- Custom Post Type, Pagination and 404s?
- Previous / Next Links For Custom Post Type Sorted By Meta_Value
- custom taxonomy pagination 404 error
- Custom archive page for custom taxonomy and pagination issue
- posts_per_page in custom WP_Query does not override “Reading” settings?
- Exclude a specific post in a Custom Post Type
- Custom post type paging return home page
- Filtering posts based on three taxonomies
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- SEARCH QUERIES – REVERSE OUTPUT
- Error in the page of a CPT file in WordPress
- post_type incorrect for custom post type
- Make pagination work as a carousel (custom query)
- Staggering featured post using ‘sticky’
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- subtracting the current post form then whole loop, which is generating all CPT titles
- Mix Facebook and Twitter feed into custom posts
- next_posts_link() always generates second page link on custom post type
- Strange behavior on WP_query
- How To Loop Through list with Custom Post Types
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Custom Post Type + Category archive
- Loop with Custom Post Type and Taxonomies
- display news with pictures 3 small and one large (loop)
- 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
- Pagination not working with custom loop
- Pagination not working with custom loop
- Custom post-type’s pagination not working in category.php
- Pagination not working on homepage
- Query Custom Post Type by Tag
- Archive page – problem with pagination
- display custom post type from register taxonomy
- Custom post type and have_posts() return empty result
- How can I show posts with the same tag?
- SOLVED: Shortcode to display Divi project filtered by tag in WP Query loop
- “Page not found” while on page 2 from pagination menu