Skip to main content
Corrected code, rushing too much
Source Link
Malisa
  • 589
  • 2
  • 11

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots.

add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); 
function yoast_no_home_noindex($string= "") {
   $term_id = get_the_category( $post->ID );
      if($term_id$term_id[0]->term_id === 92) {
         $string= "index"noindex,follow"; nofollow";
      }
      return $string; 
}

Same again, just drop this into your themes functions file.

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots.

add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); 
function yoast_no_home_noindex($string= "") {
   $term_id = get_the_category( $post->ID );
      if($term_id = 92) {
         $string= "index,follow";
      }
      return $string; 
}

Same again, just drop this into your themes functions file.

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots.

add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); 
function yoast_no_home_noindex($string= "") {
   $term_id = get_the_category( $post->ID );
      if($term_id[0]->term_id == 92) {
         $string= "noindex, nofollow";
      }
      return $string; 
}

Same again, just drop this into your themes functions file.

Source Link
Malisa
  • 589
  • 2
  • 11

As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using get_the_category As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots.

add_filter('wpseo_robots', 'yoast_no_home_noindex', 999); 
function yoast_no_home_noindex($string= "") {
   $term_id = get_the_category( $post->ID );
      if($term_id = 92) {
         $string= "index,follow";
      }
      return $string; 
}

Same again, just drop this into your themes functions file.