WordPress.org

Support

Support » How-To and Troubleshooting » if function works, but appears in plaintext on the site too

if function works, but appears in plaintext on the site too

  • Hi, I can’t figure out how to get round this, I only tinker with PHP through using WordPress, so I’m sure it’s a pretty simple fix.

    I’m trying to display a brief message to adblock users, in place of the ad.

    So here’s the portion of code from sidebar.php:

    <script>
    //Google AdSense stuff..
    </script>
    
    if (typeof(window.google_render_ad) == "undefined") {
    <div id="adblock">
    //My message
    </div>
    }

    But on the page, I see the message, but also the if code before and after.

    I tried putting the whole if(){} statement in <?php ?> tags, but that screwed with the whole formatting of the page, and the message didn’t display at all.

    Thanks in advance for any tips.

  • The topic ‘if function works, but appears in plaintext on the site too’ is closed to new replies.
Skip to toolbar