I’m trying to create a plugin that gives you a push notifications button, through the WordPress editor and I can’t find a way to get the permalink of a draft post before its status is set to published.
The predicted permalink already show up in the editor, I just can’t find how I can retrieve the same value in my code. get_post_permalink()
and get_permalink()
don’t work until the post is published.
Thx in advance!
1 Answer
You can use get_sample_permalink()
Call get_sample_permalink( $id )
or if you want to pass your own title or slug into it, the full signature is get_sample_permalink( $id, $title = null, $name = null)