Title: JSON posts pagination
Last modified: August 22, 2016

---

# JSON posts pagination

 *  [yahyooz](https://wordpress.org/support/users/yahyooz/)
 * (@yahyooz)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/json-posts-pagination/)
 * Hi,
    I am using JSON API plugin to fetch json data to my mobile application,it
   is really good plugin and thanks for that. I am trying to do pagination for my
   posts page. now I am getting only 10 items whenever i call the array. I know 
   I can change wordpress settings to get more than 10 but what i want to do is 
   pagination or infinite scrolling for better user experience. is there a way to
   do that! Thanks
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [tyandor](https://wordpress.org/support/users/tyandor/)
 * (@tyandor)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/json-posts-pagination/#post-5575509)
 * I second this request.
 *  [pelayo.mao](https://wordpress.org/support/users/pelayomao/)
 * (@pelayomao)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/json-posts-pagination/#post-5575543)
 * I would also thank an advise!
 *  [bruno.carvalho](https://wordpress.org/support/users/brunocarvalho/)
 * (@brunocarvalho)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/json-posts-pagination/#post-5575546)
 * Hello . I made a code in which the posts are loaded via a button, but can be 
   easily adapted.
 *     ```
       //Loop
       <div class="wrp">
       <ul>
   
       <?php
   
       $loop = new WP_Query( array( 'post_type' => 'download', 'orderby' => 'id', 'order' => 'DESC', 'posts_per_page' => 5) );
   
       global $post;
       ?>
       <?php
       if ( $loop->have_posts() ) :
       while ( $loop->have_posts() ) : $loop->the_post(); 
   
       ?>
       <li>
       <?php echo get_the_title(); ?>
       </li>
   
       <?php endwhile;
       endif;
       wp_reset_postdata();
       ?>
   
       </ul>
       <a href="#" class="loadMore">Load More <i class="fa fa-spinner fa-spin"></i></a>
       </div>
       ```
   
 *     ```
       //JS
       $(document).ready(function() {
   
       var currentPage = 2,
       base = 'http://MYDOMAIN.COM/', //URL for your site
       query = '?json=get_posts&post_type=download&page='+currentPage; // The query for getting posts 
   
       $('.loadMore').click(function(e){
       e.preventDefault();
   
       var button = $(this),
       unavailable = button.hasClass("unavailable");
   
       if (unavailable === false) {
       button.find('i').fadeIn();
       $.getJSON( base+query+"&dev=1", function( data ) {
       var posts = data.posts,
       pages = data.pages,
       if (paginas > 1 && currentPage <= pages) {//Check if exist more posts
       $.each(posts, function(i, posts){
       var title = posts.title.toString();
       $(".wrp ul").append('<li>'+title+'</li>');
       });
       currentPage++;
       } else {
       button.addClass("unavailable");
       }
       button.find('i').fadeOut();
       });
       }
       });
       });
       ```
   
 *     ```
       //SCSS
       .loadMore {
       color: #ffffff;
       padding: 15px;
       background-color: red;
       transition: all 200ms ease-in-out;
       margin: 20px 0;
       display: inline-block;
       &:hover {
       opacity: 0.7;
       }
       &.unavailable {
       cursor: not-allowed;
       opacity: 0.3;
       }
       .fa {
       display: none;
       }
       }
       ```
   
 * Good luck 😉

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘JSON posts pagination’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [mobile application](https://wordpress.org/support/topic-tag/mobile-application/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)

 * 3 replies
 * 4 participants
 * Last reply from: [bruno.carvalho](https://wordpress.org/support/users/brunocarvalho/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/json-posts-pagination/#post-5575546)
 * Status: not resolved