echo <a> tag, with or without rel=”nofollow” depending on page, wordpress

I want to echo out an link to a site A in the footer of site B, so that it is more seo friendly and not flagged as a site wide link, and ignored / given less weight to, id like to set it to rel=”nofollow”, apart from on the home page.

Is there a simple way to do this in word press something like :

if ($page == 'homepage') {
        echo "<a href="#">Site A</a>";
    } else {
        echo "<a href="#" rel="nofollow">Site A</a>";
}

Related posts

Leave a Reply

2 comments

  1. Try using the global WordPress variable $pagename.

    $pagename = get_query_var('pagename');
    if ($pagename == 'homepage') {
            echo "<a href="#">Site A</a>";
        } else {
            echo "<a href="#" rel="nofollow">Site A</a>";
    }