link to internal page wordpress
I'm a newbie to wordpress, I added a new page via dashboard, and I want to make a link to this page from the home page so I would love to know what function does that,
I think it would be something like: >LINK
Thanks in advance!!
You could use
<a href="<?php echo get_page_link( get_page_by_title( PAGE_NAME )->ID ); ?>">Link Title</a>
Where PAGE_NAME is the page title you have set in the dashboard.
get_page_by_title() returns an object and we use get_page_by_title( PAGE_NAME )->ID to return the page ID of that page. Note that it is more consistent to rely on the page title (which you set yourself) against page ID (which is set by wordpress).
get_page_link() retrieves the permalink of that page ID you passed as parameter.
You can simply link to the page in the HTML body of the home page. For example:
<a href="/index.php/your-page">your page</a>
<a href="index.php?page_id=###">your page</a>
Where ###, put the post ID.
If you are editing a template, and wish to obtain the permalink of the post using its ID, use get_permalink($id)
Based on your comments, you have to switch the permalink format. In WP Admin, find Permalink Settings, and set them to /%postname%/