How to get wordpress page url or link by page or post name

to get the URL of a page by its name in WordPress first you need to get the id of the page by page name and then you have to get the page URL by id

Now to get the id of the page by page name use the below code
$page = get_page_by_title( ‘Hellow World’ );
$page_id = $page->ID;

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 $page = get_page_by_title( 'Hellow World' ); ?>
<?php $page_id = $page->ID; ?>
<?php echo get_page_link($post_id ); ?>

Thanks for Reading

Share The Post On -