Forums

How to output this sitemap link only on the homepage footer. (14 posts)

  1. copywrite2012
    Member
    Posted 2 years ago #

    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

  2. Chris_K
    Member
    Posted 2 years ago #

    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."

  3. copywrite2012
    Member
    Posted 2 years ago #

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

  4. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Which file are you editing?

  5. copywrite2012
    Member
    Posted 2 years ago #

    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

  6. copywrite2012
    Member
    Posted 2 years ago #

    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.

  7. Chris_K
    Member
    Posted 2 years ago #

    What theme are you using?

  8. copywrite2012
    Member
    Posted 2 years ago #

    One given to me by a friend

  9. alchymyth
    The Sweeper
    Posted 2 years ago #

    have you studied the references i gave you in here http://wordpress.org/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.

  10. copywrite2012
    Member
    Posted 2 years ago #

    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

  11. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    What's "footer wp-admin:"? Do you mean your theme's footer.php file?

  12. copywrite2012
    Member
    Posted 2 years ago #

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

    Then I click on Appearance > Footer

    Thanks

  13. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

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

  14. copywrite2012
    Member
    Posted 2 years ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.