見せたくないページにだけ「検索よけ」をつける
WordPress
できたー!
ココを参考に
特定の親カテゴリとその子カテゴリのみに反映させたいとき
function.php にこれを記述
function post_is_in_descendant_category( $cats, $_post = null ){ foreach ( (array) $cats as $cat ) { $descendants = get_term_children( (int) $cat, 'category'); if ( $descendants && in_category( $descendants, $_post ) ) return true; } return false; }
header.php にこれを記述
<?php if ( in_category(22) || post_is_in_descendant_category(22)):?> <meta name="robots" content="noindex"> <?php endif;?>