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
- How to create a custom search for custom post type?
- what is the correct way to compare dates in a WP query_posts meta_query
- How do you use a CPT as the default home page?
- Can a custom post type have a Parent Page?
- don’t publish custom post type post if a meta data field isn’t valid
- Custom pagination for custom post types (by names)
- Linking Two Post Types
- Custom Taxonomy with Custom Post Type Finds No Posts
- Changing the URL Structure of a Paginated Custom Post
- WordPress search: pretty URLs (permalinks), custom post types and pagination
- add_rewrite_rule and custom variable
- Pagination in plugin with custom post type
- Fix custom query pagination without changing site-wide posts-per-page settings
- Custom Post Types, Page Templates and Pagination. Why do I get a 404 Error?
- Restrict categories to a custom post type
- Programmatically adding posts
- Keep main articles and author blogs seprerate, News / Magazine like site
- Sub-Sub-Blogs — creating and importing content into a custom sub-type
- Custom post type archive page pagination
- Custom post type archive not regarding ‘posts_per_page’ => -1
- Custom Post Type, Saving Multiple Checkboxes
- Show Two custom Post type and their posts on category page
- How to create an advanced filter search?
- Get rewrite slug of custom post type in template
- Placeholder in HTML editor text area?
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- Pagination on a custom post type loop
- Page vs Custom Post Types Differences/Issues
- Display only one post each WEEK
- How to Mass Delete Images from Media Library
- List custom taxonomy specific to one custom post type
- Hide parent categories when clicked, and show it’s childs
- Custom template Page 2 not working
- delete_published_posts does not work
- custom post type pagination error 404
- non-hierarchical post type with hierarchical url structure
- Next Post links not working in custom post type shortcode
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Best structure / rewrite rules to achieve the following url
- Cant get paginations on single.php to work with my custom post types
- 404 Error on form submission within custom post type
- Remove Quick edit for custom post type?
- Custom WP_Query always respond with 200 status even when no entry
- Can’t use pagination with custom taxonomy
- Displaying multiple post types on home page
- Get_the_terms restrict output
- Conflict between wp_list_pages and get_posts – list pages not displaying
- Custom ordering of CPT items not matching with the ordering of its pagination
- Break up posts per page in two sections
- List All Custom Post Types Posts in Nav Menu Dynamically
- post_content is stripping HTML when adding a new post? [closed]
- How to list custom post types on a custom post type page?
- How to export custom post type with ACF to individual file with automation?
- Different videos for different posts
- Add Class according to the order of appearance
- Post visibility option to theme front-end for author to select?
- Custom taxonomy not saving correctly
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Can I get an auto-populated dropdown list of other custom posts in a custom post edit page?
- Previous / Next Links For Custom Post Type Sorted By Meta_Value
- Custom archive page for custom taxonomy and pagination issue
- Custom post type paging return home page
- WordPress next post by ajax call on button click
- Remove plugin settings from post creation page for a user role
- Pagination on custom post type without plugin
- pagination problem listing custom post types of taxonomy in wordpress
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Permalink for custom post type pages not working
- How to display custom post type pagination buttons when processing AJAX request
- Set a Default CPT taxonomy by taxonomy id
- Adding specific custom fields (images) to post excerpt
- My post loop needs to have 8 different post templates
- Pagination with a custom post type
- WordPress deletes custom posts instead of trash them
- Pagination URL in Custom Content Type
- yet another: custom post type with pagination not working in WordPress
- Child Theme problems
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- Pagination fault in custom post type archive page [duplicate]
- Sort by Custom Post Type (Multiple Loop)
- Selecting which pages to display custom post type on using checkbox
- Custom post type blog pagination conflict
- Custom post type pagination, single page issue
- Displaying information from Custom Fields in template with Types?
- WordPress Load more posts by ajax not working
- Pagination not working with custom loop
- 2 language CPT content
- Is There A Way To Add Another Field To Custom Post Type (Not Custom Field/Meta)?
- What’s the best way to show custom post types? With page template it’s not perfect!
- Pagination not working for archive
- WordPress getting problem with pagination [duplicate]
- Exposing custom fields to the user in custom type post
- Pagination not working only on Archive-Name.php using new WP_Query
- How to display *block number* instead *date value* on WordPress posts?