Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!!

like image 666
Ben Avatar asked Dec 26 '12 23:12

Ben


People also ask

How do I change internal links in WordPress?

Update URLs After Moving a WordPress Site The easiest way to update old links on your website is by using the Go Live Update Urls plugin for WordPress. It's a free WordPress plugin and lets you update URLs in your posts, pages, images, excerpts, widgets, and more.

What is an internal page link?

An internal link is any link from one page on your website to another page on your website. Both your users and search engines use links to find content on your website. Your users use links to navigate through your site and to find the content they want to find.


1 Answers

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.

like image 106
RRikesh Avatar answered Oct 25 '22 18:10

RRikesh