How to add a link only to a specific page in WordPress

You can either add a link in index / home page or any other individual WordPress blog page using a short code, you have to place directly in the page template like in the example bellow.

In this example, I have been adding a link only to the first page / index page of the website. In my case, the home page is using a template which is used as well by another pages pointed out from next and previous button. It was useless to add the link, as it is, as a HTML chunk, into the template code because that link will appear (due the fact that other pages are using the same template) on other pages of my website, too.

[sourcecode language='php']< ?php if ( $paged < 2 ) { ?>Check my latest work, Top Best Web Hosting< ?php } ?>[/sourcecode]

paged < 2 means the first page which is using this template – my case, the home page
e.g. if you want to add a link on the second page which is using index template,too, you will use:

$paged = 2

In the same manner you can make the entire page looks different, not only adding a single link but adding different content, tags, divs, different colors and graphic elements, etc

Practically is not anymore a matter of template used. With this method you can manipulate entire pages in seconds.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

3 Comments

Leave Comment