How to get WordPress page url by id

to get the URL of any post or page in WordPress first you need to get the id of that page or post, and for that go to admin panel and open the post or page for edit and on URL you will find ?post=<post id> and get the post or page id from there.

Now Keep the page or post id in a variable
Example:
$post_id = 40;

Then call the function get_page_link() and pass the post id through the function and print it and you will get the id

Now here is the full code

<?php $post_id = 40; ?>
<?php echo get_page_link($post_id ); ?>

Thanks for Reading

Share The Post On -