Lightly tested in org-mode -- will test more and update later in time
(defun custom/org-transclusion-content-org-link (link plist)
"Return a list of payload from Org LINK object and PLIST.
This function is intended to be used for Org-ID. It delegates the
work to
`org-transclusion-content-org-buffer-or-element'."
(save-excursion
;; First visit the buffer and go to the relevant element if
;; search-option is present.
(let* ((path (org-element-property :path link))
(search-option (org-element-property :search-option link))
(search-option-numberp (if (and search-option (string-match "\\`\\([0-9]+\\)\\'" search-option))
t
nil))
(buf (find-file-noselect path))
(org-link-search-must-match-exact-headline
;; Don't ever prompt to create a headline when transcluding
(if (eq 'query-to-create org-link-search-must-match-exact-headline)
t
org-link-search-must-match-exact-headline)))
(with-current-buffer buf
(org-with-wide-buffer
(org-transclusion-content-org-buffer-or-element
(cond
(search-option-numberp
(goto-line (string-to-number search-option))
t)
((stringp search-option)
(org-link-search search-option)
t)
(t nil))
plist)))
)))
(advice-add 'org-transclusion-content-org-link :override #'custom/org-transclusion-content-org-link)
Updates
Fixed an issue when search-option-numberp failed when search-option was null.
Lightly tested in org-mode -- will test more and update later in time
Updates