• I want all of my posts and pages not to be indexed for search engines except the front page, page ID 157 & 161, and post ID 334.
    I have come up with the following code but doesn’t seem to be working.

    <?php if( ! is_front_page( ) || ! is_page( 157,161 ) || ! is_single( '334' ) ) {
    	echo'<meta name="robots" content="noindex, nofollow" /> ';
    } ?>

    The exclusion does not work and it prints the meta tag for all the pages and posts.
    Can someone tell me what’s wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Hi sasori390

    Try it with:

    <?php if( ! ( is_front_page() || is_page( 157,161 ) || is_single( '334' ) ) ) {
    echo'<meta name="robots" content="noindex, nofollow" /> ';
    } ?>

    Thread Starter sasori390

    (@sasori390)

    Hi keesiemeijer,

    It worked with a small tweak.
    For some reasons “is_page( 157,161 )” only works for 157, not 161.
    So I changed to this and it worked.

    <?php if( ! ( is_front_page() || is_page( '157' ) || is_page( '161' ) || is_single( '334' ) ) ) {
    echo'<meta name="robots" content="noindex, nofollow" /> ';
    } ?>

    Hope this is ok.
    Thanks a million!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple conditional not working’ is closed to new replies.