DocumentationOnline documentation for Ajax Load More
Sticky Posts
Display Sticky Posts
As of Ajax Load More 2.14.1
, sticky posts can be included at the top of a post listing by simply including sticky_posts=”true” in a shortcode.
<?php
echo do_shortcode( '[ajax_load_more sticky_posts="true"]' );
PHPThis snippet will display all sticky posts by passing post IDs to the post__in shortcode parameter.
$sticky = get_option( 'sticky_posts' );
$sticky = implode( ', ', $sticky);
echo do_shortcode( '[ajax_load_more post__in="'. $sticky .'"]' );
PHPRemove Sticky Posts
This snippet passes sticky post IDs to the post__not_in shortcode parameter.
$sticky = get_option( 'sticky_posts' );
$sticky = implode( ',', $sticky );
echo do_shortcode( '[ajax_load_more post__not_in="'.$sticky.'"]' );
PHPThis snippet uses the alm_query_args() filter to globally remove sticky posts from all Ajax Load More listings.
function my_custom_alm_query_args( $args ) {
$sticky = get_option( 'sticky_posts' );
$sticky = implode( ', ', $sticky );
$args['post__not_in'] = $sticky;
return $args;
}
add_filter( 'alm_query_args_', 'my_custom_alm_query_args');
PHP