Try
$u = 0;
foreach($photos as $photo) {
$u++;
...
if( ($params['next'] > 0 && $u == $params['next']) ) {
$retVal['content'] .= "<!--nextpage-->\n\n";
$u = 0;
}
EDIT (explaination)
in the code posted by OP $params['next'] > 0 && $i == $params['next']
assuming $i
is incremented every foreach cycle (this is not visible in the code, but it can be intuited) when $i > $params['next']
this not work and the next content is added once.
In my code, using $u = 0
after adding <!--nextpage-->\n\n
it should work because $u is incremented again by foreach so my code if( $params['next'] > 0 && $u == $params['next'] ) {
should works for every multiple of $params[‘next’].
Related Posts:
- Setting posts per page in query_posts
- How do I move/order posts with a tag to the end?
- How to handle paged param in post and custom-post-type?
- Number of posts in the archive
- Custom Pagination based on Custom Post Type
- Pagination on with query_posts in custom post type template
- Permalink structure by Post Meta value
- How to integrate video slide using custom post types?
- Pagination of Custom Post Types not Changing Posts
- A question on creating filters for custom posts using taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- List custom taxonomy specific to one custom post type
- Define new user capability for custom post types?
- How to allow visitors to enter custom post type?
- Paging doesn’t work?
- Is it possible to create relational metabox values in a custom post?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Meta query for custom post type ignored in main query
- Help with Elementor Pagination CPT archive 404 problem
- 2 Templates 1 custom post type according url
- changing meta value and meta key of price field
- WordPress sort search results by custom order
- Custom taxonomy rewrite give pagination 404
- Next and Previous Posts of Same Parent
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Hide parent categories when clicked, and show it’s childs
- Custom Path/Folder behind a custom post type
- Time based access control of custom post types – what is good approach?
- Show titles, date of all posts on single category page
- Add Pagination on Custom Post Type Archive
- Woocommerce search pagination not working
- Custom template Page 2 not working
- delete_published_posts does not work
- How to start a new post with custom Taxonomies already set?
- WooCommerce sort products by the actual product width(not the shipping width)
- Create a custom php page and load it at a specific slug
- Structure of data : CPT + terms
- How do you paginate a query grouped by month?
- Default text in a specific post type, but not visible?
- Update postmeta Parent when post_status child change
- List all posts in a custom post type with pagination (the correct way)
- Category with post type pagination returns 404
- WP_Query custom post type query not showing the exact post type
- custom post type pagination error 404
- How To Show All Custom Post Types In A Category Instead Of Pagination?
- Pagination issue on category.php using custom post type query
- Shortcode to display Staff post type based on Location post type and Specialty post type
- How to remove post listing page for a custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- Custom Post Type Pagination Paginates Only in URL Structure
- Is it possible to to use custom post type types on a page with the same slug somehow?
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- WordPress custom post query with pagination
- A form that can save/edit after first input
- Adding the_content() in custom template email
- Cannot save CPT meta box
- non-hierarchical post type with hierarchical url structure
- Send notification to the admin when new custom post is submitted
- How do i search authors from search form using author’s name
- Allow users to create posts without logging in?
- Next Post links not working in custom post type shortcode
- How to add attributes to taxonomies that may be different from post to post?
- Pages are not saving due to custom post type
- Custom Theme With Custom Loops
- Querying Custom Post Type, ordering by Custom Taxonomy Pagination Not Working
- Custom Post Types strange pagination problem
- Migrating a taxonomy’s tags to the native category
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- How to produce a sub-page-system in WordPress
- can these 3 queries be re-written as 1 query?
- Custom post type pagination – always return first page
- Best structure / rewrite rules to achieve the following url
- don’t publish custom post type post if a meta data field isn’t valid
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- pagination not working for category.php (custom post types in categories)
- How to sort posts in a custom post type by title in ascending order by default?
- Custom post type pagination 404
- Categorise Custom Post Types
- Detect inside a custom query the kind of post type to assign custom classes
- Pagination broken by naming conflict between CPT and Page
- Cant get paginations on single.php to work with my custom post types
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Edit the_content() function so to add a div wrapper
- How do you make a custom post type items automatically delete items 3 months after publication?
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- custom post data – how to
- Ordering Submenu Pages in WP 3.1
- 404 Error on form submission within custom post type
- Pagination custom post type not working with rewrite slug
- Pagination Not Working for Custom Taxonomy with Custom Query – 404 Error
- Pagination Error : Duplicate argument being outputted
- Custom URL redirect in WP
- Remove Quick edit for custom post type?
- Replace dynamically content in a custom database table when a custom post is created
- Custom WP_Query always respond with 200 status even when no entry
- How to customize work area / admin area in a custom post type without plugins?
- Can’t use pagination with custom taxonomy
- How can I have different content for different countries?
- Change “empty trash” button text?