• 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!

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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

    Thread Starter myrnatheminx

    (@myrnatheminx)

    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.

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

    Thread Starter myrnatheminx

    (@myrnatheminx)

    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!

    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.

    Thread Starter myrnatheminx

    (@myrnatheminx)

    Figured it out–thanks!

    What was it?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Stop Ad From Showing Up On Pages’ is closed to new replies.