Page permalinks in WordPress

PHP Web Design

Got myself puzzled for a bit while slicing a WordPress theme this weekend on how to get a permalink to a certain page in WordPress template, given that you know what’s page title. Use this:

<?php echo get_permalink(get_page_by_title("Page title here")->ID); ?>

So now in your template you can use like this:

<a href="<?php echo get_permalink(get_page_by_title("About")->ID); ?>">About</a>

Leave a Reply

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.