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 veriable
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 -

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.