Custom Fields
Re-Envisioned
Support MB Relationships pre_get_posts to get all posts connected to single object Reply To: pre_get_posts to get all posts connected to single object

#11702

Anh Tran
Keymaster

Hi Juanita,

I can’t see 2 screenshots :(.

But I think the problem is the way you get query var. The get_query_var should not be used in this situation as it gets the value from the main query. Please replace the code with:

$id = $query->get('relation_id');
$from = $query->get('relation_from');
$to = $query->get('relation_to');