How to Code a WordPress Footer Link to Show for Homepage Only

It’s important that web designers be able to credit themselves by adding a footer link to a website in the footer, but with the recent Google algorithm changes, having your link on every page of the site is actually a negative ranking factor with regard to SEO. You’re much better off with an internal page with a blurb and a link within the content or with a single link on the homepage in the footer.


For most clients, and in most situations, adding the footer credit link is much easier, and clients will seldom mind its addition there, especially if it’s only located on a single page of their site.

Change Your Footer Link to Show Only on the Homepage

In your footer.php file within the active WordPress theme you’ll want to add this bit of code where you’d like the link to appear:

<!--?php if (is_front_page()) { ?-->
<a href="">Anchor Text Here</a>
<!--?php } ?-->

The code above should work for any given theme. It’s better than this code, which may not work on some advanced themes, but does generally work fine:

<!--?php if (is_home()) { ?-->
<a href="">Anchor Text Here</a>
<!--?php } ?-->

Now, as a side note, you can add non-link text within the code as well such as:

<!--?php if (is_front_page()) { ?-->
Some other non anchor footer text <a href="">Anchor Text Here</a>
<!--?php } ?-->

For some themes, the footer.php file may not actually be where you need to add this code. Most themes have something in the footer, however, such as a copyright. You can use Textwrangler or Notepad++ to do a multifile search and look for the copyright code. Then you will have found the correct footer file.

We’ve changed the footer.php files on all of our client sites to only show on the homepage and our link profiles look much more natural. We highly advise using the above code to make your WordPress footer credit link appear only on the homepage.


15 Replies to “How to Code a WordPress Footer Link to Show for Homepage Only”

  1. Michael says:

    I like the following variant: pick an interior page, perhaps one that has context relevant to the link and then make the link show up only on that interior page. It’s based on this : is_page(42); where 42 is the ID of the page where you want the link to show up

    1. Ryan Howard says:

      You can also drop the code in a widget area by making use of one of the php text widget plugins available.

  2. Pieter says:

    Awesome!! Thanks

  3. Paul says:

    Hi, I just used this code and it worked a treat thanks.

  4. zituz says:

    Awesome, man.
    I use the first code : front_page and it’s work in several premium theme for my client site. Many thanks for this 🙂

    1. Ryan Howard says:

      Glad you could make use of it (=

  5. Thomas Jones says:

    Hi Ryan,

    How would you go about this in a wp plugin? lets say i have a 3 img alt tags.

    brand name
    web design
    thomas jones

    obviously i dont want them to keep changing dynamically just pick one and stick to it after installation of the plugin.

    how would you go about this?

  6. jasa p says:

    nice article. thanks

  7. Geoff says:

    Could you please advise where to place it in twenty eleven theme relative to the existing do_action?

    Also, what if I want other pages to show the credit but not the link – what code do I add for non-home pages?

    This is the 2011 code at present:

    <a href="” title=””>


  8. Marc says:

    nice, thanks ! Straight forward solution

  9. Anand Rao says:

    I spent hours trying to make it work. Then I stripped out
    “!– ” and “–” in your code and it worked!
    Wonder why these were put in?

    1. Ryan Howard says:

      Good catch, and sorry about that. We changed to a new plugin to allow us to add code blocks to our posts, and it must have added those commented out lines automatically. Should be good to go now.

  10. Dale says:

    The Widget is the best implementation, because if you alter the theme code or wordpress code directly, it will be overwritten on updates.

    1. Ryan Howard says:

      You can avoid overwriting modifications you make to your active theme by using a child theme. Much more flexible, easy to set up, and will revolutionize your efficiency in updating the WordPress core and your theme.

  11. Oskar says:

    Thanks, I needed this tutorial to help me include a link back to my site on my clients’ websites.

Comments are closed.