WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] footer: only show a line when on home.php (18 posts)

  1. ladydelaluna
    Member
    Posted 8 years ago #

    Okay, I've checked the forums and the codex, and came up with something like this:

    <?php if (is_home()) { ?>
    <br /><a href="http://www.linktomysite.com">Link Text</a>
    <?php } ?>

    To put in the footer, so that this only shows up when the visitor is on the home page (which is home.php)

    But... it's not working.

    I'm trying to make it so that MY link shows up in the footer only on that home page (it's the web dev credit link) and not across the whole site...

    I've searched the codex, read the conditional tags page, gone to PHP tutorial sites, and I'm lost...

    What am I missing?

  2. jwurster
    Member
    Posted 8 years ago #

    I use the following which works and also one for is_home():

    <?php if ( is_single() ) : ?>
    <h2>Navigation</h2>
    <ul class="menublock">
    <li><?php previous_post('%','&laquo; Previous Page', 'no'); ?></li>
    <li><?php next_post('%','Next Page &raquo;', 'no'); ?></li>
    </ul>
    <?php endif // is_single() ?>

  3. ladydelaluna
    Member
    Posted 8 years ago #

    Okay, but I don't want it to show up on EVERY "single" page... I only want it to show up on the home page.

    There are TONS of pages on the site using single.php... I'm talking about ONLY having this on home.php, which overrides index.php...

    Other than that, the content between the php tags really means nothing - yours appears to be for a sidebar navigation and mine is a hard coded link...

    Reminder - this is going in the footer.php file... not the sidebar.

  4. jwurster
    Member
    Posted 8 years ago #

    I use the same construct with the is_home() function.

  5. ladydelaluna
    Member
    Posted 8 years ago #

    Okay, but how is that different than what I posted that I have used that isn't working then?

    edit - i changed my start and end to yours, and nothing's showing up.

    I now have this in there:

    <?php if ( is_home() ) : ?>
    <a href="http://www.linktomysite.com" target="_blank">Link Text</a>
    <?php endif // is_home() ?>

    ... not working, at all - I don't see this anywhere...

  6. jwurster
    Member
    Posted 8 years ago #

    I just tried the following and it works for me:

    <?php if ( is_home() ) : ?>
    <br /><a href="http://www.linktomysite.com">Link Text</a>
    <?php endif // is_home() ?>

    This is what you have. What theme are you using?

  7. ladydelaluna
    Member
    Posted 8 years ago #

    It's a HEAVILY modified theme... I'm quite sure that nothing out there would resemble it anymore... LOL

    We've got custom queries and a million modifications.

    Essentially, the structures we're using are home.php, single.php, page.php, archive.php footer.php, and two conditional use sidebars that only show up here and there around the site...

  8. jwurster
    Member
    Posted 8 years ago #

    Maybe you have it a a block of code that is overwritten by something after it. Just a thought, since I can't actually see your code.

  9. ladydelaluna
    Member
    Posted 8 years ago #

    here's the entire piece of code for my footer - as it sits right now...

    </div>
    <!--<div class="clearingdiv">&nbsp;</div>-->
    </div>

    <div id="footer">
    One line of company information, name, phone, address, etc.

    <?php if ( is_home() ) : ?>
    <a href="http://www.linktomysite.com" target="_blank">Link Text</a>
    <?php endif // is_home() ?>
    </div>
    </div> <!-- ishome|issingle|isarchive -->

    </body>

    </html>

    Incidentally - the one line of company information shows up perfectly fine...
    it's MY info that's not showing up at all anywhere...

  10. Medizinische Abkuerzungen
    Member
    Posted 8 years ago #

    And if you use

    <?php if ( is_home() ) echo "< a href=\"http://www.linktomysite.com\" target=\"_blank\">Link Text"; ?>

  11. jwurster
    Member
    Posted 8 years ago #

    Did you try a hard refrsh Ctrl-F5 to clear the cache?

  12. ladydelaluna
    Member
    Posted 8 years ago #

    I switched it to your code, Stefan - still nothing. :(

  13. ladydelaluna
    Member
    Posted 8 years ago #

    That's the only way I do refresh when I'm making code changes...

  14. Medizinische Abkuerzungen
    Member
    Posted 8 years ago #

    show the result of is_home is it 1/true on every page?

    echo is_home();

  15. jwurster
    Member
    Posted 8 years ago #

    Try putting <p></p> around your 'one line of company info' and see if that makes a difference.

  16. ladydelaluna
    Member
    Posted 8 years ago #

    All the p tags did was change the horizontal alignment to the left instead of the right... (I tried that with both of your codes)

    Stefan - I'm not sure what you mean... can you please clarify that last post?

  17. ladydelaluna
    Member
    Posted 8 years ago #

    got some help from chait - thanks dave!

    this had to do with some custom queries in the home.php file that had to be tinkered with...

    i'm now sure that had the home.php file been "normal" that either one of the above solutions would've worked properly.

    thanks jwurster and stefan for your help!

  18. dannybcastillo
    Member
    Posted 7 years ago #

    Thanks for this post.

    This was my outcome. I needed a link in my main nav to disappear when a visitor travels to single or category view.


    <?php if ( is_home() || is_page() ) : ?>
    <a href="#ASI_navigation"
    title="Go to Addition Source of Information Section">
    Asi
    <?php endif // is_home() || is_page() ?>

Topic Closed

This topic has been closed to new replies.

About this Topic