Hi HivePress community,
I’m looking to improve how “Related Listings” work on my site.
Currently, HivePress displays related listings based on the most specific (child) category of a listing. The problem is that in many cases, these subcategories contain very few listings (sometimes only one), which results in no related listings being shown at all.
What I would like to achieve instead:
-
If a listing belongs to a subcategory, the related listings should be pulled from its parent (main) category.
-
This way, even if the subcategory is small, users will still see relevant listings from the broader category.
Example:
-
Listing category: Cars → Classic Cars → 1980s
-
Current behavior: shows related only from “1980s” (often empty)
-
Desired behavior: show listings from “Classic Cars” (parent category)
My questions:
-
Is there a built-in way in HivePress to change this behavior?
-
If not, what would be the best way to override the related listings query?
-
Has anyone implemented a fallback logic like:
-
try subcategory
-
if empty → use parent category
-
Any guidance or code examples would be greatly appreciated.
Thanks in advance!