Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

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

Source: 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

Source: 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

Source: https://wordpress.org/plugins/addthis/

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

ShareThis

Source: 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

Source: https://jetpack.com/

$(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

✏️ Note: 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!