The post_limits
Hook in WPFTS
The post_limits
hook in WordPress is a filter that allows modification of the SQL LIMIT
clause used to restrict the number of posts selected. WPFTS uses this hook to store the original LIMIT
value, set by WordPress, in the WP_Query
session. This is necessary for the correct operation in split_the_query mode.
What WPFTS does when post_limits
is called:
-
Saving the original
LIMIT
value: WPFTS saves the value passed to thepost_limits
filter in the session$wpq->wpftsi_session['limits']
. This is the originalLIMIT
value set by WordPress or other plugins. -
Returning the original value: The plugin returns the original
LIMIT
value unchanged. This means that WPFTS does not directly modify the post count limit in the query at this hook.
Important functions involved in post_limits
processing:
WPFTS_Search::index_post_limits()
How to use this in addon development:
Addon developers working with pagination and WPFTS need to understand that the plugin saves the original LIMIT
value and does not change it at this hook. Modification of LIMIT
in WPFTS occurs at later stages of query processing, specifically in the WPFTS_Search::index_posts_fields()
method, where it is determined whether to use a split query. If your addon also modifies LIMIT
, ensure that your logic does not conflict with WPFTS.
Additional notes:
-
WPFTS uses the saved
LIMIT
value to determine the split query mode and for correct pagination operation. -
This hook is called for all
WP_Query
queries, but WPFTS only processes it for queries related to search.