My colleague was working on an issue where we needed a permalink of the draft post. So he used get_permalink() function to get post permalink. However the get_permalink() returns URL something like https://example.com?p=6 and we needed full permalink something like https://example.com/post-slug/
The get_permalink() function returns full permalink for the published post only. He explored WordPress codebase and he found get_sample_permalink() which returns an array containing the sample permalink with a placeholder for the post name, and the post name.
Leave a Reply