WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 28.Actions and filters / How to Change Default Query Settings Per Page Type

How to Change Default Query Settings Per Page Type

59 views 0

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 the wpestate_query_2026_params filter instead.
  • Context-specific overrides are already applied. For example, when the context is
    'map', the fields key is already set to 'ids' and
    no_found_rows is already set to true before your filter fires. You can
    still change these values in your callback if needed.
  • Always return the $defaults array. If your callback does not return
    the array, the query will receive null instead of defaults and will fail.
28.Actions and filters

Related Articles

  • How to Add Custom Field Filters to Property Queries
  • How to Map Custom Search Form Fields to Query Parameters
  • How to Inspect or Replace Query Results After Execution
  • How to Modify the Final WP_Query Arguments

WP Residence Documentation

  • 01. Getting Started
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 02. Installation & Setup
  • 03. Installation FAQ
  • 06. Search & Filtering
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 09. Agent, Agency & Developers
  • 08. Property Pages & Layouts
  • 07. Property Lists, Categories & Archive
  • 13. WPResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • 04. Theme Options & Global Settings
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • 20. Translations & Languages
  • 26. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 19. Included Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 24. Technical how to | Custom Code Required
    • 25. Technical: Child Theme

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API