WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to show link on homepage only? (6 posts)

  1. BakingandBooks
    Member
    Posted 5 years ago #

    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!

  2. MichaelH
    Member
    Posted 5 years ago #

    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

  3. BakingandBooks
    Member
    Posted 5 years ago #

    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?

  4. MichaelH
    Member
    Posted 5 years ago #

    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.

  5. BakingandBooks
    Member
    Posted 5 years ago #

    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'; }

  6. BakingandBooks
    Member
    Posted 5 years ago #

    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. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.