Want link only to showing on homepage-Wordpress

Why doesn’t this work for me? I am trying to output this sitemap link only on the homepage.

On the footer.php file I have
PHP Code:

<?php get_footer(); ?>

I added this code in the WP admin html footer that I found on the net
 <?php if ( is_home() AND !is_paged() ) { ?> 
<a href="sitemap.xml">Sitemap</sitemap> 
<?php } ?>
that didn't work so I tried this
<?php if ( is_home() ) { ?> 
<a href="sitemap.xml">Sitemap</sitemap> 
<?php } ?> 

but the link is shown across all pages.

How can I get this to work? Thanks

Why not just use <?php include(“sitemap.php”); ?>
on your homepage with your code: <a href=“sitemap.xml”>Sitemap</sitemap> on the sitemap.php page?

Not sure why is_home() isn’t working. :confused:

Maybe you’re redirecting a “page” to be the home page? If so, you could use is_page(‘pagename’) replacing “pagename” with the slug for the “page” that is being redirected to the front page. Though I could be way off. :blush:

So try this out:

<?php if ( is_front_page() ) { ?> 
 <a href="sitemap.xml">Sitemap</sitemap> 
<?php } ?>

Hope it helps. :slight_smile: