• 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:
    [HTML]
    <?php get_footer(); ?>
    [/HTML]

    [HTML]
    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><a href="sitemap.xml">Sitemap</sitemap>
    <?php } ?>

    [/HTML]
    but the link is shown across all pages.

    How can I get this to work? Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • Make a small correction to your first try:

    <?php if ( is_home() AND !is_paged() ) { ?>
      <a href="sitemap.xml">Sitemap</a>
    <?php } ?>

    I’m not sure where your sitemap.xml file is relative to your blog so you might also need to give a fully qualified link to it instead of just “sitemap.xml.”

    Thread Starter Copywrite

    (@copywrite2012)

    Thanks for the reply but it still doesn;t work (it is the same code surely?!)

    Which file are you editing?

    Thread Starter Copywrite

    (@copywrite2012)

    Hi Esmi,
    The footer.php file I added this code:

    <?php wp_footer(); ?> <?php if ( is_home() AND !is_paged() ) { ?>
      <a href="sitemap.xml">Sitemap</a>
    <?php } ?>

    Thanks

    Thread Starter Copywrite

    (@copywrite2012)

    If I put the code on the WordPress Admin
    Appearance Footer file then the Sitemap text and link is shown on all pages not on the index page.

    What theme are you using?

    Thread Starter Copywrite

    (@copywrite2012)

    One given to me by a friend

    have you studied the references i gave you in here https://www.ads-software.com/support/topic/397179?replies=4 ?

    sometimes you need to try and use ‘is_front_page()’ instead of ‘is_home()’

    so I have to create a new page and put it in the domain root?

    no, you would make a new footer file in the folder of your theme.
    make sure to understand and follow the naming convention.

    however, from this thread, it seems that you could just work within the existing footer.php of your theme; and make the edits there.

    Thread Starter Copywrite

    (@copywrite2012)

    Thanks for the answer. I am a bit confused.
    This is what I now have on index.php:

    <?php
    if ( is_home() ) :
      get_footer('home');
    else :
      get_footer('');
    endif;
    ?>

    Then on the footer I have:
    <?php wp_footer(); ?>

    Then I have this code on the footer wp-admin:

    <?php wp_footer(); ?>
    <?php if ( is_home() AND !is_paged() ) { ?>
      <a href="/sitemap.xml">Sitemap</a>
    <?php } ?>

    I also created a file called footer-page.php

    The code always shows the link on both the front page and the inside page whether it is is_home or is_frontpage

    How can I make this work? Thanks

    What’s “footer wp-admin:”? Do you mean your theme’s footer.php file?

    Thread Starter Copywrite

    (@copywrite2012)

    Hi Esmi,
    Footer wp-admin is found when I login to mydomain.com/wp-admin.

    Then I click on Appearance > Footer

    Thanks

    It sounds like your theme uses dynamically created footer content. What’s in the theme’s footer.php file?

    Thread Starter Copywrite

    (@copywrite2012)

    Thanks for the reply, here is the footer code:

    <div class="art-Footer">
        <div class="art-Footer-inner">
                    <a href="<?php bloginfo('rss2_url'); ?>" class="art-rss-tag-icon" title="RSS"></a>
                    <div class="art-Footer-text">
    <p>
    <?php
     global $default_footer_content;
     $footer_content = get_option('art_footer_content');
     if ($footer_content === false) $footer_content = $default_footer_content;
     echo $footer_content;
    ?>
    </p>
    </div>
        </div>
        <div class="art-Footer-background">
        </div>
    </div>
    
    		<div class="cleared"></div>
        </div>
    </div>
    <div class="cleared"></div>
    <p class="art-page-footer"></p>
    </div>
    
    <!-- <?php printf(__('%d queries. %s seconds.', 'kubrick'), get_num_queries(), timer_stop(0, 3)); ?> -->
    <div><?php wp_footer(); ?> </div>
    </body>
    </html>

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to output this sitemap link only on the homepage footer.’ is closed to new replies.