• Resolved bimmerime

    (@bimmerime)


    hi,
    i’m using this code to display adsense code under my header

    <?php if( !is_page( array(‘about-us’, ‘contact’, ‘privacy-policy’, ‘terms-of-use’) ) ) : ?> adsense code <?php endif; ?>

    i would like to add 404 pages to the excluded ones, what should i add?

Viewing 10 replies - 1 through 10 (of 10 total)
  • @bimmerime, To execute 404-page from your script, you can add something like…

    <?php
    // under else part?
      status_header( 404 );
      nocache_headers();
      include( get_query_template( '404' ) );
      die();
    ?>

    Alternate way…

    <?php
    if( !is_page( array('about-us', 'contact', 'privacy-policy', 'terms-of-use') ) ) { ?>
      adsense code
    <?php } else {
      include(TEMPLATEPATH . '/404.php');
    } ?>
    Thread Starter bimmerime

    (@bimmerime)

    tired that but now all those( contact, about us ,……….) pages returns a 404

    @bimmerime, Share full-code here.

    Thread Starter bimmerime

    (@bimmerime)

    this is the code i’m using,

    <?php if( !is_page( array(‘about-us’, ‘contact’, ‘privacy-policy’, ‘terms-of-use’) ) ) : ?> adsense code <?php endif; ?>

    i tried the second one you gave me but all those 4 pages give a 404 error.
    what i want is to exclude the adsense code to show under my header on the 404 pages

    @bimmerime, You mean you want to add adsense in the header of all the pages, excluding 404 page? Provide more info. on your question please.

    Thread Starter bimmerime

    (@bimmerime)

    yes exactly, the code i’m using already exclude the contact and about us ……… pages and i would like to exclude the 404 pages

    @bimmerime, Try this…

    <?php
    if( !is_page( array('about-us', 'contact', 'privacy-policy', 'terms-of-use') ) && !is_404() ) { ?>
      adsense code
    <?php } ?>
    Thread Starter bimmerime

    (@bimmerime)

    didn’t work, i’m still seeing the ad in my 404 pages

    @bimmerime, I’ve updated the recent code. Try it.

    <?php
    if( !is_page( array('about-us', 'contact', 'privacy-policy', 'terms-of-use') ) && !is_404() ) { ?>
      adsense code
    <?php } ?>
    Thread Starter bimmerime

    (@bimmerime)

    Thank you, it worked perfectly.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘add 404 pages to the excluded pages’ is closed to new replies.