post_limits_request filter
Filters the LIMIT clause of the query.
apply_filters_ref_array( 'post_limits_request', string $limits, WP_Query $query )
Description
This hook is used for caching plugins. However this filter applies to the LIMIT clause of the query before the query is sent to the database, allowing you to define a new query LIMIT.
Parameters
- $limits : (string) The LIMIT clause of the query.
- $query : (WP_Query) The WP_Query instance (passed by reference).
Live Example
To run the hook, copy the example below.
$array = apply_filters( 'post_limits_request', $array); if ( !empty( $array ) ) { // everything has led up to this point... }
The following example is for adding a hook callback.
add_filter( 'post_limits_request', 'wp_post_limits_request_filter', 10, 2 ); /** * Function for `post_limits_request` filter-hook. * * @param string $limits The LIMIT clause of the query. * @param WP_Query $query The WP_Query instance (passed by reference). * * @return string */ function wp_post_limits_request_filter( $limits, $query ){ // filter... return $limits; }
To remove a hook callback, use the example below.
// remove the filter remove_filter( 'post_limits_request', 'filter_post_date_column_time', 10, 4 );