Greetings!
I have the following code inside of a pre_get_posts
action:
if (false !== get_query_var(SERVICE_VAR, false)) {
$service = Service::get_controller();
if ($service instanceof Service) {
$query->set('relationship', [
'id' => get_relation_id('post', SERVICE_TYPE),
'to' => $service->id
]);
}
}
This is being used on the post archive (blog) in the main query. I've stepped through the code in XDebug and can confirm that the relationship query is being added, but it doesn't appear to be working. I'm actually switching from Piklist to Meta Box, and the old Piklist query modifier works, so I know the code overall is working; the Meta Box relationship is not working. I've double-checked that the relationships and such are in place.
Is there something distinct I need to do in pre_get_posts? Or do I need to make sure my hook is at a certain priority?
Thanks!