Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
101 lines (77 sloc) 3.31 KB

Auto Load Next Post Documentation

alnp-post-loaded

The alnp-post-loaded callback is public JavaScript function dispatched after every successful Ajax load by Auto Load Next Post. The callback can be used to trigger functions in other JavaScript files, manipulate DOM content or simply console.log a message for debugging – how you utilize the callback is completely up to you.

Usage Examples

The following callback examples are used to initiate 3rd party scripts after successful Ajax requests.

Developers: You can copy and paste these into your theme so your theme supports these plugins with Auto Load Next Post.

Easy Fancybox - https://wordpress.org/plugins/easy-fancybox/

You can either use this code snippet or use the events section via the Auto Load Next Post settings to trigger Easy FancyBox.

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    $(document.body).trigger('post-load');
  });
})(jQuery);

AddToAny - https://wordpress.org/plugins/add-to-any/

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    if ( window.a2a_config ) {
       a2a.init_all("page"); // Trigger AddToAny
    }
  });
})(jQuery);

Addthis - https://wordpress.org/plugins/addthis/

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    if ( typeof addthis !== 'undefined' ) {
      addthis.layers.refresh(); 
    }
  });
})(jQuery);

ShareThis - https://www.sharethis.com/

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    if ( window.stButtons ) {
      stButtons.locateElements();
    }
  });
})(jQuery);

Facebook Comments, Like Button, Share etc.

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    FB.XFBML.parse();
  });
})(jQuery);

Jetpack - Tiled Galleries

$(function() {
  $('body').on( 'alnp-post-loaded', function( e, params ) {
    var base_url = 'http://mywebsite.com';
    $.getScript( base_url + "/wp-content/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js" );
  });
})(jQuery);

Other 3rd party plugins

These plugins have not yet been tested with Auto Load Next Post.


If you have any issues with this guide, or the documentation that is linked throughout, please open a new issue in this repository for it to be reviewed. Thank you!

You can’t perform that action at this time.