• I am trying to get conditional tags to work to show Adsense on specific Pages, and not on others. The approach I use below isn’t working:

    <?php if (is_page(181,182,183)) {
    echo ‘Adsense code’;
    }
    else {
    echo ‘Affiliate code’;
    }
    ?>

    I tried this too for multiple page arguments with no success:

    <?php if ( is_page(181) || is_page(182) || is_page(183) ) {
    echo ‘Adsense code’;
    }
    else {
    echo ‘Affiliate code’;
    }
    ?>

    any ideas on where I am messing up?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter entropicus

    (@entropicus)

    Another approach that seems logical, which avoids using Echo, but doesnt work, is to concatenate the Pages you don’t want the code to show. But this doesn’t work either:

    <?php if(!is_page(181) || !is_page(182) || !is_page(183) || !is_page(184) || !is_page(185) || !is_page(186) || !is_page(187)): ?>
    <!– Google Code –>
    <script type=”text/javascript”><!–
    google_ad_client = “”;
    google_ad_width = 336;
    google_ad_height = 280;
    google_ad_format = “336x280_as”;
    google_ad_type = “text”;
    google_ad_channel = “”;
    google_color_border = “FFFFFF”;
    google_color_bg = “FFFFFF”;
    google_color_link = “6B8F16”;
    google_color_text = “000000”;
    google_color_url = “000000”;
    //–>
    </script>
    <script type=”text/javascript”
    src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>
    <?php endif; ?>

    Thread Starter entropicus

    (@entropicus)

    I resolved this and post it so it might be of use to someone else. The expression for “not”, “!” should be stated once before the iteration to test each multiple conditional begins.

    This works perfectly:

    <?php if (!( is_page(181) || is_page(182) || is_page(183) || is_page(184) || is_page(185) || is_page(186) || is_page(187) )) { ?>

    <script type=”text/javascript”><!–
    google_ad_client = “”;
    google_ad_width = 336;
    google_ad_height = 280;
    google_ad_format = “336x280_as”;
    google_ad_type = “text”;
    google_ad_channel = “”;
    google_color_border = “FFFFFF”;
    google_color_bg = “FFFFFF”;
    google_color_link = “6B8F16”;
    google_color_text = “000000”;
    google_color_url = “000000”;
    //–>
    </script>
    <script type=”text/javascript”
    src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>
    <?php } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Adsense Conditional on Specific Pages?’ is closed to new replies.