For Bloggers: How to Add a Link to WordPress Homepage Only

1 Shares Twitter 1 Facebook 0 Google+ 0 Pin It Share 0 StumbleUpon 0 1 Shares ×

As a WordPress user, it can be very easy to add links to your sidebar and footer using widgets. The content included in these widgets will appear on every page of your WordPress blog. Sometimes you may have a link that needs to be placed on your WordPress homepage only. This may happen when working with advertisers. They may wish to add a link to your WordPress homepage and you’re left with a job you may not know how to handle!

How to Add a Link to WordPress Homepage Only

There are two options for adding a link to your homepage. You can add a PHP script to have WordPress display links or any other content you desire only on your homepage.

php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
PLACE CONTENT FOR THE HOMEPAGE ONLY HERE
php } ?>

Replace the words “PLACE CONTENT FOR THE HOMEPAGE ONLY HERE” with the code for the link or other content you would like to display only on the homepage of your WordPress blog. Add the PHP script to your theme files using the Theme Editor or FTP and you are good to go… unless you want to place it in a widget and then this approach will not work for you and brings me to the second approach.

How to Add a Link to Your WordPress Homepage Only (Widgets too!)

Since PHP codes are not executed in WordPress widgets, if you want to add the link to your sidebar or footer and only have it display on the homepage, there is a plugin for that! (It seems like there is a plugin for almost everything!)

Search for and install the Exec-PHP plugin. Activate the plugin and configure it, if necessary. Then you can add the code above into any of your widgets and your link will show up in your chosen location on the homepage only!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge