How to Create Infinite Scroll Pagination

How to Create Infinite Scroll Pagination

Tutorial Details
  • Program: WordPress
  • Difficulty: Intermediate
  • Estimated Completion Time: 40 minutes

Infinite scroll pagination is inspired from Facebook and Twitter. This is just pagination where the user will need to scroll to bottom of the page to read more articles. This is one way to improve the user experience on a website, but if you do it wrong, it can give a bad experience too. If you’re going to implement this type of pagination, make sure you don’t include important links at the bottom of the page. The reason for this is that when a user tries to click on that particular link, the page will auto load new entries and push the link off the screen each time. You can either set a fixed position footer area or make your sidebar visible all the time.


Step 1 Plan Your Pagination

It is important that you plan ahead with your pagination, where you want to include it, and how you are going to process it. A common way of doing pagination is by listing the page numbers at the bottom of the page. Using this method however, no more page numbers will appear at the end of your article list, as they’re no longer needed. This pagination can be use on all themes as long as you don’t include loads of information in your footer section, as it may not give the desired effect.

Our infinite scroll pagination will use jQuery and ajax functionality to make the request and retrieve more articles to be shown to the user. In this tutorial, I will use the Twenty Ten theme as an example, you can view the working demo of the infinite scroll here.


Step 2 Building the Ajax Function

We will use WordPress’ ajax functionality to make the call for this pagination. First we prepare the basic function for our pagination, please insert the following code to your theme’s functions.php

function wp_infinitepaginate(){ 
    $loopFile        = $_POST['loop_file'];
    $paged           = $_POST['page_no'];
    $posts_per_page  = get_option('posts_per_page');

    # Load the posts
    query_posts(array('paged' => $paged )); 
    get_template_part( $loopFile );

    exit;
}

This function will be used to make the call for our pagination, basically we send two variables to this function via ajax, one is the page number and another is the file template we are going to use for our pagination. To enable this function to be used with WordPress ajax, we need the following code.

add_action('wp_ajax_infinite_scroll', 'wp_infinitepaginate');           // for logged in user
add_action('wp_ajax_nopriv_infinite_scroll', 'wp_infinitepaginate');    // if user not logged in

The default action for WordPress ajax would be wp_ajax_(our action name), hence why the name infinite_scroll being used in the code example. We need to add two actions, one for logged in users and another is for users that are not logged in.

Next we will need to build the ajax function that will send the two variables we need for our pagination. You can use WordPress hooks to insert this jQuery ajax function or straight away insert it into your theme header.php

<script type="text/javascript">
function loadArticle(pageNumber) {
	$.ajax({
		url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
		type:'POST',
		data: "action=infinite_scroll&page_no="+ pageNumber + '&loop_file=loop', 
		success: function(html){
			$("#content").append(html);    // This will be the div where our content will be loaded
		}
	});
	return false;
}
</script>

This will be the basic ajax call that we are going to make and we use “infinite_scroll” as our action name. WordPress will automatically call our function wp_infinitepaginate(); because we define it in our theme functions.php previously.


Step 3 Determine When the User Scroll to Bottom of Page

To enable the infinite scroll pagination, we need to determine when the user hits the bottom of the page. This can be achieved easily via jQuery using the following code.

<script type="text/javascript">
            $(window).scroll(function(){
                    if  ($(window).scrollTop() == $(document).height() - $(window).height()){
                          // run our call for pagination
                    }
            }); 
</script>

Now we can know when the user hits the bottom of the page. Next we need to call the loadArticle function within the scroll function. I’m adding a counter to be used as the page number of our call.

<script type="text/javascript">
            var count = 2;
            $(window).scroll(function(){
                    if  ($(window).scrollTop() == $(document).height() - $(window).height()){
                       loadArticle(count);
                       count++;
                    }
            }); 

            function loadArticle(pageNumber){    
                    $.ajax({
                        url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
                        type:'POST',
                        data: "action=infinite_scroll&page_no="+ pageNumber + '&loop_file=loop', 
                        success: function(html){
                            $("#content").append(html);   // This will be the div where our content will be loaded
                        }
                    });
                return false;
            }
</script>

Each time the user scrolls to bottom of the page, the counter will increase and this will enable us to have the page number pass to our wp_infinitepage() function within our theme’s functions.php. With the scroll and loadArticle functions, we can now do the ajax function call within our WordPress theme, but the result may not appear if we haven’t defined the loop file within our theme folder.


Step 4 Setting Up Our Theme

Most important thing, we need to setup the div that will hold the new content that’s been requested using our ajax function. In the Twenty Ten theme, there is already a div we can use, which is the div with id="content" so we will include the div id in our ajax function. If you use other themes that don’t wrap their loop in a div, you can simply wrap the loop function like the example code below to achieve the same result.

<div id="content"> loop content </div>

Next we will need a loop file for this. The Twenty Ten theme already has a loop file included, this is the main reason why I chose Twenty Ten for this example, because it is easier for anyone who wants to reference this later. If you don’t have any loop.php, simply create a new loop file, and copy the loop function within your index.php into the new file and uploaded it into your theme’s folder. For anyone using the Twenty Ten theme, you would want to comment out the pagination included in the file because we won’t need it anymore (please refer to the tutorial source file on how to do this).


Step 5 Adding Ajax Loader

This is optional, just to give a nice touch to our infinite scroll pagination. We will add an ajax loader image as we hit the bottom of the page. You can add the following code to your footer.php

<a id="inifiniteLoader">Loading... <img src="<?php bloginfo('template_directory'); ?>/images/ajax-loader.gif" /></a>

and then add the following CSS to your stylesheet.

a#inifiniteLoader{
	position: fixed;  
	z-index: 2;  
	bottom: 15px;   
	right: 10px; 
	display:none;
}

Next we will add a few lines of code to our jQuery function to show and hide this ajax loader element.

  <script type="text/javascript">
        jQuery(document).ready(function($) {
            var count = 2;
            $(window).scroll(function(){
                    if  ($(window).scrollTop() == $(document).height() - $(window).height()){
                       loadArticle(count);
                       count++;
                    }
            }); 

            function loadArticle(pageNumber){    
                    $('a#inifiniteLoader').show('fast');
                    $.ajax({
                        url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
                        type:'POST',
                        data: "action=infinite_scroll&page_no="+ pageNumber + '&loop_file=loop', 
                        success: function(html){
                            $('a#inifiniteLoader').hide('1000');
                            $("#content").append(html);    // This will be the div where our content will be loaded
                        }
                    });
                return false;
            }
    
        });
       
    </script>

The ajax loader will be shown once the user hits the bottom of the page and will be hide once the ajax request has finished.


Step 6 Additional Limitation to Enhance the Infinite Scroll

Up till now, we already have a working infinite scroll, but one thing is missing. The function will keep triggering each time a user hits the bottom page even though there are no more post to be shown. This is something we don’t want to have. We will add a control in our scroll function so when there no more pages to be shown, it will stop.

<script type="text/javascript">
var count = 2;
var total = <?php echo $wp_query->max_num_pages; ?>;
$(window).scroll(function(){
	if  ($(window).scrollTop() == $(document).height() - $(window).height()){
		if (count > total){
			return false;
		}else{
			loadArticle(count);
		}
		count++;
	}
}); 
</script>

We add a new var total to the function which will return the total pages available on our site. This will be used to ensure no additional calls will be made to the page if the maximum page has been reached. Another thing we would want to add is a restriction where this function will be loaded. We just want this on our home page, archive or maybe search, but not on our single post and page. So we wrap a simple PHP if else function in our jQuery code.

if (!is_single() || !is_page()):
// our jQuery function here
endif;

That’s pretty much everything you need for the pagination, please refer to the source files for example code used in this tutorial. The files are based on the Twenty Ten theme.


Conclusion

By now you should be able to use this function in any of your theme, if you have any additional suggestions or questions regarding this tutorial, feel free to leave a comment or contact me via twitter. Would love to share any ideas with you guys.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Hein Zaw Htet

    Very helpful for me.

  • Al

    usually find this feature annoying, kind of like being on an endless treadmill, I do hope that everyone does not implement this feature

    Al

    • Eddie Monge

      So you prefer endlessly clicking and waiting for the page to refresh and redraw everything?

    • http://desyna.com Neo

      Rock that scroll wheel I say – It’s a whole lot easier to scroll than click ; )

    • Mart

      What about on mobile devices, would you rather have clicks or scrolling on that?

    • Evert

      With webdesign it is hardly ever about what you like or don’t like, but about what works and doesn’t work. There are studies/data that suggest that infinite scoll generates more revenue than pagination. So a company would be wise to look at the sales figures and not to their personal taste.

  • http://www.paulund.co.uk Paul

    Hi

    Just wondering how does this feature affect SEO? When the crawlers come to your site do they see one post or all of your posts?

    Thanks
    Paul

    • http://kovshenin.com Konstantin

      Paul, good question, though I’d put it this way: what happens if javascript is not supported? because search engine crawlers don’t execute your javascript code. And the answer would be “nothing!” — pagination will not work and users with no javascript (as well as search crawlers) will not get past the first page of your blog.

      How do we fix this? Make sure you’re printing your pagination links no matter what. You can hide them with javascript if you want, but they have to be in the markup, leading to the correct pages. Try disabling javascript for your browser, and see if you can browse through your pages. If you can’t then you’re _doing_it_wrong() :)

      ~ K

    • dj

      For SEO, spiders will see only the HTML for the first page. They are not a browser, nor do they follow or run javascript. IF spiders can find your additional pages through some other route/link etc – then all should be well; if they can’t – then, not so much!

  • Timothy Nolte

    While the infinite scroll can be a nice fature from a user experience I think the execution of it will make or break the usability of your site for users. And you have stated this but in this design I think you missed one key aspect that is crucial for users, that is control. Instead of the allowing the very act of scrolling to the bottom of the screen being what is used to initiate an ajax call for more artiicles there should be a “Read ;ore” link that the user clicks. This gives the additional benefit of not breaking more complex footer designs. Additonally one piece that I also saw that was missing was any visual indicator that more content was loading. There needs to be some visual indicator. When I scrolled to the bottom of the demo I saw nothing and wondered if I was missing something, then the content popped up.

  • http://kovshenin.com Konstantin

    Nice, though it could be even nicer in some places. Don’t use bloginfo with a hard-coded wp-admin URL, use the admin_url function instead. Specify the data object as an array, rather than a string, that will increase readability.

    But what really bothers me is that you’re not validating or sanitizing any of the user input that you’re accepting, and passing them straight to functions like get_template_part, that might create a serious security risk.

    You should also explain what a loop file is, and why you’re using it, why a loop file doesn’t (shouldn’t) call get_header, etc, and why javascript events will not work on newly appended content, as well as how to fix that all. You should have at least provided the contents of the loop file, and the full child theme or plugin that you were crafting.

    Cheers :)

    ~ Konstantin

    • John

      Doesn’t seem to work on iPhone, I think that mobile browsing should always be considered nowdays.
      Anyway nice implementation of infinite scroll, please make more tutorials about ajax solutions in wordpress.

      Thanks :)

      John

      • Ripul

        many thanks for this comment, I almost forgot about the loop file.

    • dj

      What he said… I looked at this as something I was interesting in implementing; but, ended up with as many questions after as I had before. It seems to me that WPtuts would want to publish posts that taught/advocated ‘best practices’ or at least mentioned why it wasn’t using them and give a ‘present day’ solution as well. We probably shouldn’t assume that the majority or readers are trying to find way’s to “retro-fit” old web-sites; to me it doesn’t make sense to publish a tutorial which expects users to “revert back to” replaced versions. Again, to me, it seems that one should be expecting authors to give “solutions” based upon the current version at time of writing – heaven knows they go out-of-date fast enough!

    • http://www.eizil.com Eizil
      Author

      Thanks for the input, i will update the tutorial and provide the necessary explanation and files for all the questions you’ve asked.

    • http://maorchasen.com Maor Chasen

      Totally agree with you on these points, Konstantin. What bothers me the most is the part where some POST data is being handed to WP core function without being sanitized, thus possibly exposing the site for any other security risks.

  • Pingback: How to Create Infinite Scroll Pagination | Shadowtek | Hosting and Design Solutions

  • http://maddisondesigns.com Anthony Hortin

    One more thing. It doesn’t appear to be working in Firefox (Mac). Works ok in Safari & Chrome though.

    • http://bragthemes.com Brad

      Adding some bottom margin to the tile container fixed the firefox problem for me.

  • Pingback: Website - Navigation - Scrolling | Pearltrees

  • http://db-designs.eu Daryl

    Anyone got a demo of this live so I can quickly check it out? Cheers

  • Jubic

    There’s already a plugin for this I think http://wordpress.org/extend/plugins/infinite-scroll/

  • http://keepitindie.de markus

    Hi!

    I followed all the steps, but what is wrong if there only appear another “0” (zero) with reaching the bottom of the page? Can’t find my problem in my custom theme (isn’t online yet). Maybe you could help easily?

    As there’s no email notifiations here pls drop me a mail (infokeepitindie.de). I’ll check the comments here, too, though…

    Thanks!

    • http://www.eizil.com Eizil
      Author

      that would be info[at]keepitindie.de is it? if yes, i’ve contacted you via email.

      • http://twitter.com/ColeGeissinger Cole Geissinger

        Would you be able to share with us your solution to this? I’m receiving the same issue :( It seems the query isn’t returning any posts??

      • http://twitter.com/ColeGeissinger Cole Geissinger

        ah, just answered my question… I missed spelled infinite in the “wp_ajax_infinite_scroll’ action :P Now to figure out how to init Isotope…

  • Pingback: Weekly WordPress Review » WPCanada

  • Pingback: ASO Blog Weekly Digest: March 19-23 | Web Hosting Blog at ASO

  • Pingback: Weekly Design News – Resources, Tutorials and Freebies (N.125)

  • Pingback: Wordpress Leaks » Weekly Design News – Resources, Tutorials and Freebies (N.125)

  • westcave

    This technique is patented by Twitter, so you can’t use it without their permission. http://dcurt.is/pull-to-refresh?utm_source=hackernewsletter&utm_medium=email

    • Mart

      Infinite scroll and pull to refresh are two very different techniques. I think you may have had a misunderstanding of one or both of them.

  • http://rbarriga@gmail.com Rodolfo

    * I think the effect would be better if you use a “buffer of data” …so you can make the async call (XHR) before to get the bottom of the page …. (something like google maps)

    anyway… cool !!

    Best

  • Pingback: 《JavaScript 每周导读》【第二期】 | 编程X资讯

  • http://www.wpbeginner.com Syed Balkhi

    How does this translate into server load?

  • Pingback: 《JavaScript 每周导读》【第二期】 « NeverBest!我还能做的更好 – 007boy | im007boy

  • http://adambaney.com Adam

    Does this work with pages that call and display custom post types?

    • http://adambaney.com Adam

      I tried this infinite scroll with custom post types, and it seems to try to load more posts! Unfortunately, I only get the “Loading…” text. This also happens with my regular-old posts page. Any thoughts why this wouldn’t be working for even normal “posts”? Thanks!

      • http://adambaney.com Adam

        Too bad I can’t edit my comment… I’m using WP 3.3.1, and here are my URLs:

        Normal Posts Displayed:
        http://adambaney.adambaney.com/posts/

        Custom Post Type Posts Displayed:
        http://adambaney.adambaney.com/blog/

        • http://www.flintandtinder.co.uk Flint & Tinder

          I’m having no luck with CPT archives either. The loading gif comes up ok, but then I just get the ‘you’ve reached the end…’ message and no new posts.

          Have you managed to solve this yet?

  • http://bacsoftwareconsulting.com/blog/ Boutros AbiChedid

    Very Nice tutorial. I personally don’t like the infinite scroll pagination as other commenters pointed out from a user point of view. I find it annoying, I like regular pagination instead.
    Your code is a great starting point, but I could see where the code can be improved especially from a security point of view with data sanitization of user inputs.
    Great WordPress tutorial.
    Thanks.

  • Pingback: Как настроить бесконечную прокрутку WordPress сайта | Wordpresso

  • Mark

    Hi,

    This works great, but one thing i have noticed is once my “count” reaches 11, it stops loading any more results in firefox? continues to load results fine in IE, Chome etc.

    Any ideas?

  • Pingback: Fabulous Tutorials » Infinite Scrolling Pages in Wordpress

  • Bob

    Hi,
    This code doesn’t work well when displaying archive page. It shows posts that shouldn’t be displayed.
    e.g. for my May archives, it shows some posts of April.

    Does someone has any solution for this issue ?

    Thanks

  • http://promantic.ru Promantic

    Good morning or night.

    A have just an one problem:
    How i can do it?
    I dnk where i have to write this text.

    if (!is_single() || !is_page()):
    // our jQuery function here
    endif;

    Pls write it in detail.
    Thx.

  • Pingback: WordPress Learner’s Blog – 005 | DisjointedMedia.com

  • Pingback: Los mejores 35 tutoriales para WordPress marzo del 2012 | El blog de David Chávez s

  • abdull

    hello

    i am not using word press, can i do this on to my website ?

    is there a way to create a custom posting platform and then have this Pagination feature?

    i really need help

    thank u

  • http://www.cdmuench.com cdmuench

    So I got this to work on my category page. In the jQuery I changed the count to be 1. The issue I was having was the load of the loop would repeat the first post on my page, but on the next load it would load page 2. so in the functions file I changed the paged to $paged = $_POST['page_no'] + 1;. This fixed the issue of it starting on page 1.

    • frenchc

      Hi cdmuench, I don’t understand how you got this to work with Categories?? it’s been puzzling me for the past two weeks and doesn’t seem that anyone’s managed. I’ve tried all sorts of things, from changing the loop query to trying to amend the array passed in the function.

      any help would be appreciated

  • Paul

    I have a two-column layout based on twentyten on which I’d like to use InfiniteScroll. I tried using this script, but have two problems working with it.

    My page structure is that index.php contains two content-DIVs, calles #content1 and #content2. Each of them wraps around a custom loop file with custom post-queries.

    1. How do I tell the script to append both containers with their certain loop-content?
    2. I implemented the script as described, but the first container always loads the first posts again, not the following ones. So the posts keep repeating?!?

    Thanks for any advice!

  • Andre

    Hey! Great tutorial! Got it working with the downloaded files, but now trying to implement it into my website. Does this script works on custom page templates? I get no error’s at all, code is the same as the downloadable files. Nothing happens really, just showing page 1 and the loading animation.

    • Andre

      Might have something to do with conflicting jQuery versions. Going to do more research.

  • http://twitter.com/mortendandersen Morten Andersen

    A small fix for your functions.php

    Make the query_posts with the ‘post_status’:
    query_posts(array(‘paged’ => $paged, ‘post_status’ => ‘publish’));

    Otherwise you’ll end up seeing the same posts again, in case you have any draft, future or otherwise un-published posts.

    Great tutorial otherwise!

  • harinder

    i m using expose theme..

    Infinite Scroll Pagination is not working
    bcoze of loop file

    can U help me

  • Mike

    Is perfect it works very good, i use masonry to, in the first page works but i have a problem, i dont know how to call masonry script, any hint?

    • Mike

      —This—

      $(function(){
      var $container = $(‘#ladrillos’);
      $container.imagesLoaded(function(){
      $container.masonry({
      itemSelector: ‘.box’,
      columnWidth: 1
      });
      });

      —in this—

      jQuery(document).ready(function($) {
      var count = 2;
      var total = max_num_pages; ?>;
      $(window).scroll(function(){
      if ($(window).scrollTop() == $(document).height() – $(window).height()){
      if (count > total){
      return false;
      }else{
      loadArticle(count);
      }
      count++;
      }
      });
      function loadArticle(pageNumber){
      $(‘a#inifiniteLoader’).show(‘fast’);
      $.ajax({
      url: “/wp-admin/admin-ajax.php”,
      type:’POST’,
      data: “action=infinite_scroll&page_no=”+ pageNumber + ‘&loop_file=loop’,
      success: function(html){
      $(‘a#inifiniteLoader’).hide(’1000′);
      $(“#content”).append(html); // This will be the div where our content will be loaded
      }
      });
      return false;
      }
      });

      —- how to call the masonry script? —-

  • Mike

    —This—

    $(function(){
    var $container = $(‘#ladrillos’);
    $container.imagesLoaded(function(){
    $container.masonry({
    itemSelector: ‘.box’,
    columnWidth: 1
    });
    });

    —in this—

    jQuery(document).ready(function($) {
    var count = 2;
    var total = max_num_pages; ?>;
    $(window).scroll(function(){
    if ($(window).scrollTop() == $(document).height() – $(window).height()){
    if (count > total){
    return false;
    }else{
    loadArticle(count);
    }
    count++;
    }
    });
    function loadArticle(pageNumber){
    $(‘a#inifiniteLoader’).show(‘fast’);
    $.ajax({
    url: “/wp-admin/admin-ajax.php”,
    type:’POST’,
    data: “action=infinite_scroll&page_no=”+ pageNumber + ‘&loop_file=loop’,
    success: function(html){
    $(‘a#inifiniteLoader’).hide(’1000′);
    $(“#content”).append(html); // This will be the div where our content will be loaded
    }
    });
    return false;
    }
    });

    —- how to call the masonry script? —-

  • http://twitter.com/ColeGeissinger Cole Geissinger

    I know several people asked about using Masonry with the Infinite Scroll. Although I am not using it, I have made this work using it’s big brother, Isotope. The steps here should be fairly similar, just check the documentation.

    To use Infinite Scroll and Isotope, in the loadArticle() function, update the success callback with this.
    success: function(html) {
    $(‘#infiniteLoader’).fadeOut(’1000′);
    var $newItems = $(html);
    $(‘#content’).isotope(‘insert’, $newItems); //select our #content div that wraps all of the articles and append the fetched posts
    }

    I hope that helps answer some questions!

  • http://www.aarongmoore.com Aaron G. Moore

    I’m lost on step four. There must be something I don’t know but am expected to know because I don’t understand how replacing my current pagination with
    loop content will work. Help?

    • http://twitter.com/ColeGeissinger Cole Geissinger

      What step four is talking about is you need to make sure you have a div with an ID of “content” in your index.php or home.php (if home.php doesn’t exist, then update index.php). With out that ID, the supplied JavaScript won’t have a destination to append the new posts. The text “loop content” isn’t needed. That’s just a place holder. In your theme files this ID should surround the WordPress Loop.

      BTW, It doesn’t have to be an ID called “content” for this to work though. You can update that to be what ever you want, you just need to make sure you back track update the ID in the success field of the javascript function. I hope that answers your question?

      • http://www.aarongmoore.com Aaron G. Moore

        Thanks, that does help a bit. At least I think I understand the concept a little more clearly.

        I’m not very proficient in php, I coded my own theme using the tutorial from CSS-tricks.com

        I’ve been trying to use the “Infinite Loop” plugin for wordpress. It
        asks for a link to the next page and I didn’t think there was a link, I
        thought you just use the php to call up the paginated_links echo.

  • http://twitter.com/hawaiidesigner Hawaii Web Designer

    thank you! is there a way to make this work on iPhone Safari browser?

  • aa

    Hey I think you have a bug in is_single || is_page

    It should be &&

  • http://twitter.com/pistapera pistapera

    it does’n work with a custom query (e.g. in category or search page) because it doesn’t handle wp_query correctly. could someone help in finding a solution?

  • rockvilla

    The code in loop.php displays posts of my entire site not just of that category! :(

  • http://twitter.com/alphaalec Alec Morrison

    Has anybody managed to get this working on mobile?

  • Pingback: How to Add Infinite Scrolling to WordPress blog

  • Pingback: To Infinite Scroll or Not to Infinite Scroll: Where We’ve Come So Far | MY Thoughts | VapvaruN | Varun Kumar Dubey | VapvaruN

  • Pingback: To Infinite Scroll or Not to Infinite Scroll: Where We’ve Come So Far | Design Shack | Mrs. Web

  • jamesmvpa

    Thanks for the tutorial. I have implemented it for our Kerala recipes website with some little modifications as mentioned in the comments. Thank you once again.

  • http://twitter.com/ZaneDeFazio Zane DeFazio

    Here’s how to make this script work with an iPhone.

    Swap:
    if ($(window).scrollTop() == $(document).height() – $(window).height()){

    With:
    if ($(window).scrollTop() >= $(document).height() – $(window).height() – 60){

    I didn’t test this script outside of an iPhone, iPad and desktop browser. May not work on some Android based phones.

    Cheers!

  • Helois

    Hi,

    I want to load a function before I reach the bottom of the page. What should I do.

  • http://geekyinspirations.com/ Hemant Aggarwal

    I used it with a button click but it loads two earlier posts along with the new ones. Can you have a look at http://mstoic.com