my head looks like this: https://www.dropbox.com/s/7phmhirwzcrzvp3/head.php?dl=0 I want to add noindex,follow to certain pages and I have tried adding this
<?php if($paged > 1 || is_archive || is_404 ||is_page(array( 2,4,6 ))){echo '<meta name="robots"content="noindex,follow" />'; } ?>
but then ALL my pges except the homepage are set to noindex,follow...can someone tell me if I need to change the code or where exactly I would need to put it??
Obviously the variables and constants you use do not contain the stuff you expect them to.
Your best choice is to iterate your conditions until. Starting with…
<?php if($paged > 1){echo '<meta name="robots"content="noindex,follow" />'; } ?>
…going to…
<?php if($paged > 1 || is_archive){echo '<meta name="robots"content="noindex,follow" />'; } ?>
…and so on.
Oh, and have a look at your error log. is_archive
looks like a constant, but you might mean is_archive()
or $is_archive
. Your error log might reveal such issues - even more so, if you set error_reporting(E_STRICT);
to be especially picky about unset variables.
Another way would be var_dump();
for every variable you want to use in your condition, for you to check what content is in your variables. Like:
<?php var_dump(array($paged > 1,is_archive, is_404,is_page(array( 2,4,6 )))); ?>