DocumentationOnline documentation for Ajax Load More
Variables
The following PHP variables are accessible within Ajax Load More Repeater Templates.
$alm_page | Returns the current page number. echo $alm_page; |
---|---|
$alm_current | Returns the current item number in the Ajax Load More loop - count will reset to zero with every 'Load More' action. echo $alm_current; |
$alm_item | Returns the current item number within your entire Ajax Load More query. echo $alm_item; |
$alm_found_posts | Returns the total number of posts found in the Ajax Load More query. echo $alm_found_posts; |
$args | The $args array contains query data and other Ajax Load More related information. var_dump( $args ); |
Repeater Template Usage Examples
1 2 3 4 5 |
<!-- Accessing Variables in Repeater Templates --> <article class="alm-repeater-template page-<?php echo $alm_page; ?>"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <p>Currently viewing item #<?php echo $alm_item; ?> of <?php echo $alm_found_posts; ?></p> </article> |
1 2 3 4 5 6 7 8 9 10 |
<!-- Loading unique Repeater Template for 2nd item only --> <article class="alm-repeater-template"> <?php if($alm_current == 2){ // Do stuff for 2nd item only. } else { // All the rest. } ?> </article> |
1 2 3 4 5 6 7 8 9 |
<!-- Rendering odd/even Repeater Templates --> <article class="alm-repeater-template"> <?php if ($alm_current % 2 !== 0) { echo "Odd"; } else { echo "Even"; } ?> </article> |