Filter: wpestate_query_2026_context_defaults
This filter allows you to change the base default values that every property query
starts with. These defaults control settings like how many properties are shown per page, what sort
order is used, and whether the query returns full post objects or just IDs.
The WP Residence query engine uses four different contexts to determine what kind of
page is requesting properties: directory (listing pages), map (map pin queries), dashboard (front-end
agent panel), and featured (widgets and shortcodes). Each context has its own set of defaults. This
filter lets you change those defaults from your child theme.
When Does This Filter Fire?
This filter fires at the very beginning of the query pipeline, inside the function
wpestate_query_2026_property_context_defaults(). It runs before the
caller’s parameters are merged in. This means the values you set here act as fallbacks —
if the caller (a page template, a shortcode, or a search form) provides an explicit value for the
same setting, the caller’s value will take priority over your default.
Source file: libs/query/query2026/wpestate_query_2026_property.php
Filter Signature
$defaults = apply_filters( 'wpestate_query_2026_context_defaults', $defaults, $context );
Parameters
| Parameter | Type | Description |
|---|---|---|
| $defaults | array |
The defaults array that you can modify. This is the value you must return from your callback function. |
| $context | string |
The query context. One of: ‘directory’, ‘map’, ‘dashboard’, or ‘featured’. Use this to apply your changes only to specific page types. |
Default Values in the Array
When this filter fires, the $defaults array contains these keys with their built-in
values. Context-specific overrides (for example, map queries set fields to
'ids') are already applied before the filter fires.
| Key | Default Value | What It Controls |
|---|---|---|
| post_status | ‘publish’ | Which post status to query. Almost always ‘publish’ on the front-end. |
| paged | 1 | The current pagination page number. |
| posts_per_page | 0 | How many properties to show per page. 0 means “use the WordPress site setting” (Settings → Reading). |
| order | 0 | Sort order code. 0 = featured properties first, then by date. Codes 1–8 map to specific sort options (newest, price, bedrooms, size, etc.). |
| no_found_rows | false | When true, WordPress skips counting total matching posts. Faster, but pagination will not work. Map and featured contexts set this to true by default. |
| fields | ” (empty string) | What data to return. Empty string = full WP_Post objects. ‘ids’ = only post IDs (faster). Map context uses ‘ids’ by default. |
| tax_relation | ‘AND’ | How multiple taxonomy filters combine. ‘AND’ = property must match ALL taxonomy filters. ‘OR’ = property must match at least one. |
| meta_relation | ‘AND’ | How multiple meta (custom field) filters combine. Works the same way as tax_relation. |
| geo_lat | ” | Geolocation center latitude. Empty = no geolocation filtering. |
| geo_long | ” | Geolocation center longitude. |
| geo_rad | 0 | Geolocation search radius (in the unit configured in theme options: miles or kilometers). |
Child Theme Examples
Example 1: Show 24 Properties Per Page on Directory Listing Pages
By default, directory pages use the WordPress “posts per page” setting (Settings → Reading).
If you want directory pages to always show 24 properties per page regardless of that WordPress setting,
you can change the default like this:
<?php
/**
* Change the default number of properties shown on directory listing pages to 24.
*
* This only changes the default. If a specific page template or shortcode explicitly
* sets a different posts_per_page value, that value will override this default.
*
* Add this code to your child theme's functions.php file.
*/
add_filter( 'wpestate_query_2026_context_defaults', 'my_child_change_directory_per_page', 10, 2 );
function my_child_change_directory_per_page( $defaults, $context ) {
// Only apply to directory (listing) pages. Leave map, dashboard, and featured unchanged.
if ( 'directory' === $context ) {
$defaults['posts_per_page'] = 24;
}
return $defaults;
}
Example 2: Increase the Maximum Number of Map Pins
Map queries have a built-in limit on how many property pins are loaded (controlled by the theme option
wp_estate_map_max_pins, which defaults to 200). If you have a large number of properties
and want to display up to 500 pins on the map, you can increase this default:
<?php
/**
* Allow up to 500 property pins on map pages instead of the default 200.
*
* Note: Loading more pins means more data transferred to the browser.
* Test performance with your actual property count before increasing this value too high.
*
* Add this code to your child theme's functions.php file.
*/
add_filter( 'wpestate_query_2026_context_defaults', 'my_child_more_map_pins', 10, 2 );
function my_child_more_map_pins( $defaults, $context ) {
// Only apply to map pin queries.
if ( 'map' === $context ) {
$defaults['posts_per_page'] = 500;
}
return $defaults;
}
Example 3: Change the Default Sort Order for Featured Widgets
Featured property widgets use sort order code 0 by default, which shows featured
properties first, then sorts by date. If you want featured widgets to sort by newest first
(order code 1) instead:
<?php
/**
* Sort featured widget properties by newest first instead of the default featured-first order.
*
* Sort order codes:
* 0 = featured-first (default) 1 = newest 2 = price ascending
* 3 = price descending 4 = oldest 5 = bedrooms ascending
* 6 = bedrooms descending 7 = size asc 8 = size descending
*
* Add this code to your child theme's functions.php file.
*/
add_filter( 'wpestate_query_2026_context_defaults', 'my_child_featured_newest_first', 10, 2 );
function my_child_featured_newest_first( $defaults, $context ) {
if ( 'featured' === $context ) {
$defaults['order'] = 1;
}
return $defaults;
}
Important Notes
-
This filter changes defaults only, not forced values. If a page template,
shortcode, or search form explicitly passes a value for the same key, that explicit value will
override the default you set here. If you need to force a value that cannot be overridden by
callers, use thewpestate_query_2026_paramsfilter instead. -
Context-specific overrides are already applied. For example, when the context is
'map', thefieldskey is already set to'ids'and
no_found_rowsis already set totruebefore your filter fires. You can
still change these values in your callback if needed. -
Always return the
$defaultsarray. If your callback does not return
the array, the query will receivenullinstead of defaults and will fail.