How to get a page link from its slug or name?

admin September 29, 2016
  • page-link-slug-title

    A common query that I come across very frequently. I would like to make sure this is solved forever 😉 Here’s the key.

    Getting page permalink by page title, use following code

    
    <a href="<?php echo get_permalink( get_page_by_path( 'Page Title' ) ) ?>">Anchor Text</a>
    
    

    Getting page permalink by page slug, use following code

    
    <a href="<?php echo get_permalink( get_page_by_path( 'Page Slug' ) ) ?>">Anchor Text</a>
    
    

Comments

  • A WordPress Commenter

    A WordPress Commenter29 / Sep / 2016

    Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    Commenter avatars come from Gravatar.

Leave a comment

You must be logged in to post a comment.

Our Services

Featured Blog

Others

  • A WordPress Commenter Hi, this is a comment.
    To get started with moderating, editing, and deleting comments, please visit A WordPress Commenter

Newsletters Signup

Sign up to Our Newsletter & get attractive Offers by subscribing to our newsletters.