How to order posts by custom field when using Post Navigation?


As default, the Post Navigation element uses post ID for ordering.

Is it possible to use a custom field (number or text) to set a custom order and use that one for Post Navigation?

For example:
I have 3 posts with post id 1, 2, 3 and they have custom field values of 18, 19, 17 respectively.
By default, Post Navigation will lead me through 1 → 2 → 3.
But I want to order them by the custom field, so I would have 3 → 1 → 2

Thank you in advance.

I found this and it works for me: WordPress: sort Previous and Next post by menu_order · GitHub