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 -

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.