DocumentationOnline documentation for Ajax Load More
Implementation Methods
There are two unique ways of implementing Ajax Load More onto a page – both of the following implementation methods accept all configuration and query parameters.
Shortcode
The shortcode implementation is the OG method for adding Ajax Load More to posts, pages, and theme templates.
// Template (.php)
echo do_shortcode('[ajax_load_more post_type="portfolio"]');
// Block Editor
[ajax_load_more post_type="portfolio"]
JavaScriptPro Tip: Use the Shortcode Builder to create a formatted Ajax Load More shortcode in seconds.
alm_render
The alm_render method was added in Ajax Load More 5.0 for users who prefer to avoid shortcodes for functional implementations.
alm_render accepts an array of key/value pairs. Each key(parameter) and value must be passed as a string as shown below in the code sample.
// page-template.php
$category = 'design';
$args = array(
'post_type' => 'post',
'posts_per_page' => '6',
'category' => $category,
'button_label' => __( 'Show More Posts', 'framework' ),
'button_loading_label' => __( 'Loading...', 'framework' ),
'scroll' => 'false'
);
if ( function_exists( 'alm_render' ) ) {
alm_render( $args );
}
PHP