Replies: 1 comment
-
Unfortunately not, some core blocks have the same issue as you're having, and the only solution right now is to use a PHP render callback. What technique you use within the render callback is up to you. This new discussion seems relevant though, it proposes a token system to make this kind of thing easier - #39831. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my theme, I have a number of custom blocks that allow you to select a page. In the save function, I save the pages URL, ID and Title.
This is great, when I save the block I get:
But if the page being referenced is edited and its url updated to
http://site.dev/new-page-url
, the saved block has the out dated URL.Is there a way to put a permalink to an ID into a
save()
function?The other option I have is that I return
null
from thesave
function and instead create the template as PHP and use something like I'm used to from PHP templating likeget_permalink($attributes['link']['id'])
.However:
This feels like it must be a "solved" problem. Is there a recommended approach to this? Is there a way of having a part of a save template output a php tag?
Beta Was this translation helpful? Give feedback.
All reactions