This is an old question, but I needed the answer to this one as well. Here is the solution taken right from the WP codex…
$prev = '<div class="nav-previous">' . get_next_posts_link( __( '<span class="meta-nav">←</span> Previous' ), $loop->max_num_pages );
You need to append the max_num_pages parameter from the query to your output and it should work as expected from within the shortcode.
Related Posts:
- Shortcode Displaying Custom Post Types
- Next Post links not working in custom post type shortcode
- Where to put my code: plugin or functions.php?
- Pagination not working with custom loop
- WP_Query Pagination on single-custom.php
- Have different number of posts on first page
- Custom pagination for custom post types (by names)
- Custom post type pagination 404 fix?
- next_post_link() not working for single custom post type post
- Create a shortcode to display custom post types with a specific taxonomy
- wp_pagenavi() with custom wp_query()?
- Pagination with custom post type not working
- Custom post type archive 404’s with paginate_links
- How do I Paginate Search Results for Custom Post Types?
- Display custom post type with shortcode
- Pagination throws 404 error on custom taxonomy archive pages
- Add Content to Page without shortcodes
- Changing the URL Structure of a Paginated Custom Post
- Custom Post Type Pagination Not Working On Archive Page
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Number of pages – multiple (custom) post types
- WordPress search: pretty URLs (permalinks), custom post types and pagination
- Pre get posts for single post
- Multiple Paginations on one Page
- Archive page…limiting posts per page
- How can I fix those issues generated by the Themecheck plugin
- Pagination not working with custom category template
- Custom permalink with pagination
- Related posts by author pagination not working on the production site
- Secondary loop pagination on custom post type single post gets redirected to first page
- 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
- Custom Post Type Rewrite Rule for Author & Paging?
- Pagination go to first page if i’m on last post
- Posts in Multiple Columns and Rows with one single loop
- Pagination throws 404
- Pretty paged permalinks in custom post type loop
- Newer/Older posts links display same posts on every page
- Custom wp_query pagination – next_posts_link() or wp_pagenavi() always empty
- Pagination with custom loop
- WordPress Custom Shortcode Conflicting with Media Library
- Group list of posts by taxonomy and allow for pagination
- Custom post type archive with pagination?
- Pagination on a custom page template
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- paginate function in archive for custom-post-type
- Pagination problems with multiple custom post type archive pages
- Pagination in plugin with custom post type
- Fix custom query pagination without changing site-wide posts-per-page settings
- custom post type paging not working past page 3
- Custom Post Type, Two categories, Two columns with Pagination
- Display “Post 2 of 4” on single post page?
- posts_nav_link on single post template
- Pagination problem in custom post type used as front page
- Custom Taxonomy archive returns 404
- Pagination gives 404 error
- Paginate Custom Post Type Page
- Creating a simple pagination for custom post type templates
- WP_Query pagination using only numbers instead of /page/1 on URL
- Custom Post Types, Page Templates and Pagination. Why do I get a 404 Error?
- Using shortcodes to parse POST request (containing the data from a front-end form)
- Custom Select Query with Custom Post Types
- Pagination with custom post types results in 404 issues
- How can i list custom post type categories?
- Pagination not working
- Pagination Custom post type
- IF statement in a do_shortcode
- Pagination Issue: Custom Post Type In Index
- Custom query form submission pagination
- Paginated Taxonomy Term Archive including one post per term
- WordPress rewrite my URL when i use pagination
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- Pagination links not showing on custom post type admin list
- Strip shortcode from specific post types (formats)
- Pagination on Custom Post Type: 404 Error
- Custom Post Type Pagination & duplicate posts
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Custom post type archive page pagination
- Pagination problem
- How to load custom post archives sub-pages with ajax?
- Custom post type archive not regarding ‘posts_per_page’ => -1
- Generate Shortcodes by Taxonomy
- How would I create a shortcode to display a custom post within a page or regular post?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- pagination redirecting from page number url before page requested
- Unable to get paginate_links working with a custom query [duplicate]
- Get custom posts with certain ids in a custom loop using a shortcode
- Setting posts per page in query_posts
- Custom Post Type Loop within Shortcode
- Custom post type, permalinks & pagination, going wrong
- Shortcode insertion in tab
- Shortcode doesn’t display in custom post type
- Repeating posts when paginating random posts
- Pagination on category page with custom post types
- How to add pagination to wp_query [duplicate]
- Archive template for custom post type only lists first 10