Documentation
Online 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 post listing by simply including sticky_posts=”true” in a shortcode.
1 |
echo do_shortcode('[ajax_load_more sticky_posts="true"]'); |
This snippet will display all sticky posts by passing post IDs to the post__in shortcode parameter.
1 2 3 |
$sticky = get_option( 'sticky_posts' ); $sticky = implode( ', ', $sticky); echo do_shortcode('[ajax_load_more post__in="'. $sticky .'"]'); |
Remove Sticky Posts
This snippet passes sticky post IDs to the post__not_in shortcode parameter.
1 2 3 |
$sticky = get_option( 'sticky_posts' ); $sticky = implode( ',', $sticky ); echo do_shortcode('[ajax_load_more post__not_in="'.$sticky.'"]'); |
This snippet uses the alm_query_args() filter to globally remove sticky posts from all Ajax Load More listings.
1 2 3 4 5 6 7 8 |
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'); |