Forums

Stop Ad From Showing Up On Pages (8 posts)

  1. myrnatheminx
    Member
    Posted 2 years ago #

    Dear WordPressers:

    I have ad code that appears on the right sidebar of my blog. I added the following code so that the ad would only appear on the homepage:

    <?php if ( is_home() ) { ?>
    ad text here</br>
    <?php } ?>

    This was a partial solution. The problem is that the ad is still showing up on my individual pages. I'm not sure how to prevent that, but I need to!

    I am using the ElegantBlue theme.

    Thanks so much!

  2. songdogtech
    Member
    Posted 2 years ago #

    Does elegant blue have a file named home.php in the theme?

    Or, try (is_front_page()) if you have the home page set to be the front page in Settings/Reading

  3. myrnatheminx
    Member
    Posted 2 years ago #

    Thanks! Nope, no home.php file.

    I tried your change and it didnt work. Here is what I changed the code above to:

    <?php if ( is_front_page() ) { ?>
    "ad text here</br>
    <?php } ?>

    The ad still shows up on pages as well as the homepage.

  4. songdogtech
    Member
    Posted 2 years ago #

    Must be something in the way the theme is coded. Ask the theme author.

  5. myrnatheminx
    Member
    Posted 2 years ago #

    Would it help to know that I am adding the ad code to the sidebar.php (not home.php or index.php)? I just realized this. Whoops.

    BTW, thanks so much for trying to help!

  6. songdogtech
    Member
    Posted 2 years ago #

    Doesn't matter; php code in the sidebar will read what the current page is, but there might be other code in the sidebar by the theme author that stops it from working.

  7. myrnatheminx
    Member
    Posted 2 years ago #

    Figured it out--thanks!

  8. songdogtech
    Member
    Posted 2 years ago #

    What was it?

Topic Closed

This topic has been closed to new replies.

About this Topic