Description
Adjust the maximum number of results that can be returned in a GP Populate Anything query.
Usage
Apply to all applicable fields on all forms.
add_filter( 'gppa_query_limit', 'my_custom_function' );
Apply to all applicable fields on a specific form.
add_filter( 'gppa_query_limit_FORMID', 'my_custom_function' );
Apply to a specific field on a specific form.
add_filter( 'gppa_query_limit_FORMID_FIELDID', 'my_custom_function' );
Parameters
query_limit int
Query limit to be passed onto Object Type queries.
object_type GPPA_Object_Type
Current object type.
field GF_Field
The current field being populated.
Since
This filter is available since GP Populate Anything 1.0.
The $field
parameter and FORMID/FIELDID support was added in 1.0-beta-4.44.
Examples
Change the query limit to 750 for all dynamically populated fields.
function example_increase_limit_to_750 ($query_limit) {
return 750;
}
add_filter( 'gppa_query_limit', 'example_increase_limit_to_750' );
Change the query limit to 750 for only the post object type.
function example_increase_limit_to_750 ($query_limit, $object_type) {
if ($object_type->id !== 'post') {
return $query_limit;
}
return 750;
}
add_filter( 'gppa_query_limit', 'example_increase_limit_to_750', 10, 2 );
Change the query limit to 1000 for a specific field on a form.
In this example, we increase the query limit to 1,000 for field #3 in form #1.
function example_increase_limit_to_1000 ($query_limit, $object_type) {
return 1000;
}
add_filter( 'gppa_query_limit_1_3', 'example_increase_limit_to_1000', 10, 2 );