Custom Loader
Display a custom loader with each Ajax Load More query
In this example:
Ajax Load More will display a custom loading indicator as posts are being loaded from the server.
Using the alm_before_button filter hook and some custom CSS, a loader will be displayed above the ‘Load More’ button.
-
Ajax Load More Post Example
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Cum sociis natoque penatibus et magnis dis parturient montes,...
-
Donec ullam corper nulla metus auctor frinel
Sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum. Vestibulum id ligula porta...
-
Lorem Ipsum Maec diam eget risus varius blandit
Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum...
-
Pellentesque ornare sem lacinia quam venenatis vestibulum
Maecenas faucibus mollis interdum. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Vestibulum id ligula porta felis...
Filter
Use the alm_before_button
filter to add a #custom-alm-loader
div to the Ajax Load More container.
// functions.php
add_filter( 'alm_before_button', function() {
if( is_page( 'custom-loader' ) ){
return '<div id="custom-alm-loader"></div>';
}
} );
PHPThe following shortcode was used to create the Custom Loader example.
[ajax_load_more repeater="template_46" post_type="post, ajax_more" images_loaded="true" preloaded="true" preloaded_amount="4" posts_per_page="4" pause="true" pause_override="true"]
The following Repeater Template was used to create the Custom Loader example.