Code Samples /

pre_get_posts

In WordPress, pre_get_posts is a hook that allows for modification of an existing WP_Query before the query is run on the server.

Ajax Load More queries have a custom alm_id parameter attached to the WP_Query, this parameter allows developers to target a specific instance of Ajax Load More for modification while using pre_get_posts.

In the code sample below, an instance Ajax Load More with the ID of design-listing will be modified to return all posts of the design category.

Note: The alm_id query parameter is a direct reference to the ID shortcode parameter – you must set a unique ID to target a specific Ajax Load More query.


« Back to Code Samples