WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to show link on homepage only?

[Resolved] How to show link on homepage only?

  • Is there any way to display a selection of links only on the front page of my blog?

    I have been receiving emails from companies interested in purchasing an ad link on my blog – these are displayed in the left-hand sidebar directly beneath the BlogAds strip. However, these companies only want their link to appear on the front page, not on any other page of the site. Is this possible?

    Thank you for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • In your “sidebar” Template you would use either:

    if (is_home()){
    echo 'show links';
    }

    or

    if (is_front_page()){
    echo 'show links';
    }

    Resources:
    Conditional Tags
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    Thank you for your response MichaelH!

    Does my sidebar need to be inside the loop for this to work? I don’t think it is right now because that would be the only bit of WP code in it. Right now it’s all ul and li tags, with the sidebar div class.

    Also, what do you mean by “show links” – is that a specific Link category I should create?

    Does my sidebar need to be inside the loop for this to work?

    No, I used the WordPress Default theme to test this. I would assume you would put the code “in the left-hand sidebar directly beneath the BlogAds strip”.

    The “show links” is just a place mark for where you do your “ad link” thing.

    I just tried it and unfortunately that didn’t work on my blog. The code snippet didn’t break the site, it just showed up like text. In other words, the code showed up on the front page like this:

    – How to bake
    – Your link here
    if (is_home()){ echo ‘show links’; }

    Nevermind! I had a “duh” moment and realized I needed to put the “php” start and end tags in. That did it!

    Thanks very much. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] How to show link on homepage only?’ is closed to new replies.
Skip to toolbar