I have 2 questions
- First question. I added custom select attribute called xcustom. And I want to change related listing query but it doesnt work. what i did wrong?
add_action( 'hivepress/v1/models/listing/relate', function( $query, $listing ) {
// Set xcustom.
if ( $listing->get_xcustom__id() ) {
$query->filter( [ 'xcustom__in' => $listing->get_xcustom__id() ] );
}
}, 10, 2 );
But if I replace it with this, it works. but the weird thing is we need to re add query for categories again:
$query->set_args(
[
'tax_query' => [
'relation' => 'AND',
// Set xcustom.
[
'taxonomy' => 'hp_listing_xcustom',
'field' => 'term_id',
'terms' => $listing->get_xcustom__id(),
'operator' => 'IN',
],
// Set categories. we need this eventhough its already in 'hivepress/v1/models/listing/relate'. maybe its hivepress bug
[
'taxonomy' => 'hp_listing_category',
'field' => 'term_id',
'terms' => $listing->get_categories__id(),
'operator' => 'IN',
],
],
]
);
Seems after reading this, its a bug?
- Second question. How to make it also search for listing by the same author/vendor using hivepress query model?