How can I create a link to a specific page in wordpress?

It seems like a simple task, but I’m having difficult time finding any information on this. Basically I have an “Events” page created in wordpress to which I want to create a link on my main page. I do not want it to be static like (https://mysite.com/events). Is there a way to do it dynamically?

Related posts

Leave a Reply

1 comment

  1. You want to use the get_permalink() function to write the link – http://codex.wordpress.org/Function_Reference/get_permalink

    This function accepts an argument which is the post or page ID (and defaults to the ID of the current page), so if your Events page is ID #11, it would look like to following to also have the link text match the page title (should it change to “Events!” in the future, for example):

    <?php $events_page = get_post(11); ?>
    <a href="<?php echo get_permalink($events_page->ID); ?>"><?php echo $events_page->post_title; ?></a>