Help targeting Related Listings query by city attribute on single listing page

Hi HivePress team,

I’m using HivePress for a yoga teacher directory and I’m trying to customize the Related Listings section on the single listing page.

Goal

On a single listing page, I want the Related Listings block to show:

only listings from the same city as the current listing (using the city attribute), and

ideally keep the default “related” logic besides that (so just restrict to same city, not replace everything).

What I’ve tried

I inspected the single listing template and confirmed the Related Listings section is the standard HivePress block at the bottom of the listing page.

I tried hooking into hivepress/v1/models/listing/search_query to add a meta_query filter based on the current listing’s city attribute, but it looks like I’m not targeting the correct query context for the Related Listings block.

The order of listings changes when I experiment, which tells me I’m affecting some query, but the related listings are still not restricted to the same city.

Questions

Which query context / filter does HivePress use for the Related Listings block on a single listing page?

For example, what should I check in the $context[‘name’] value inside hivepress/v1/models/listing/search_query to know I’m modifying the correct query?

What is the recommended way to filter the Related Listings block by a listing attribute like city (stored as a listing attribute, not taxonomy)?

A short code example of how to correctly hook into the related listings query and add a meta_query (or other recommended filter) based on the current listing’s city value would be very helpful.

Context

WordPress: 7.03

HivePress: 1.7.27

Theme: Blocksy

The city field is a HivePress listing attribute.

Thanks in advance for any guidance or sample snippet you can share. I’m just trying to keep the Related Listings block native, but filter it so visitors see other listings from the same city as the one they’re viewing.

Thanks

Thanks for your message — our team will reply shortly.

In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.

Hi,

Welcome to the community! :herb:

Could you please let me know whether City is a custom attribute in your case or whether you’re referring to the city provided by the Geolocation extension?

If City is a custom attribute, you can enable the Include in related criteria option in the attribute settings. This will allow related listings to be displayed based on the attribute value.

If the city comes from the Geolocation extension, you can select Location under HivePress > Settings > Listings > Related Listing Criteria.

Hope this helps