How to Add Homepage-only Links to WordPress
Posted by admin on Jun 20th, 2010
If you are trying to add a link to your WordPress blog which will only show up on the home page and are frustrated by the fact that WordPress does not have built in support for doing doing so look no further. There is a simple and quick way to accomplish this.
By using several lines of PHP code in your WordPress theme file you can easily add a link or any other content (such as a widget or photos) that you only wish to show up on the home page of your blog. Here it is:
<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
{HOMEPAGE-ONLY CONTENT HERE}
<?php } ?>
Getting this script to work is very easy. Simply add the link code instead of “{HOMEPAGE-ONLY CONTENT HERE}”. Then use the “Theme Editor” to put it into the theme files, wherever you want it be.
Please note that this script will not work if placed in the “widgets” area because PHP code is not executed in the “Widgets” section. However this too can be easily accomplished by installing the Exec-PHP plugin. Enable the plugin then configure it and add the above php code to a text widget.


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sed felis. Aliquam sit amet felis. Mauris semper, velit semper laoreet dictum, quam diam dictum urna, nec placerat elit nisl in quam. Etiam augue pede, molestie eget, rhoncus at, convallis ut, eros. Aliquam pharetra. Nulla in tellus eget odio sagittis blandit. Maecenas at nisl. Nullam lorem mi, eleifend a, fringilla vel, semper at, ligula. Mauris eu wisi. Ut ante dui, aliquet nec, congue non, accumsan sit amet, lectus. Mauris et mauris. Duis sed massa id mauris pretium venenatis. Suspendisse cursus velit vel ligula. Mauris elit. Donec neque. Phasellus nec sapien quis pede facilisis suscipit. Aenean quis risus sit amet eros volutpat ullamcorper. Ut a mi. Etiam nulla. Mauris interdum.