Craft 5x Field Linktype: Is there a way to get linked entry from native Link field (similar to Hyper)? #17609
|
Hi, I’m currently using the Hyper plugin, but I’m exploring a transition to Craft’s native Link field and was wondering if the following is also possible with the native field: When I link to an Entry in a Hyper field, I can access the linked Entry id and compare it to the current entry: When I use the native Link field and link to an Entry, the field returns something like: My question: Is it possible to access the linked Entry ID in any way when using the native Link field? I would need it for active nav state logic. Would love to know if there’s an approach I’m missing — or if this is just a limitation of the native field type. Thanks in advance! |
Answered by
brandonkelly
Jul 14, 2025
Replies: 1 comment 2 replies
|
Yep, you can fetch the linked element using the getElement() method on the link field’s value: {% set element = entry.myLinkField.getElement() ?? null %} |
2 replies
Answer selected by
brandonkelly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, you can fetch the linked element using the getElement() method on the link field’s value:
{% set element = entry.myLinkField.getElement() ?? null %}