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