- 카테고리 및 기사페이지에서 작동
- 봇 크롤링 제외는 robots.txt에서 별도 처리 필요
- Yoast SEO의 경우 wpseo_robots 필터, Rank Math SEO는 rank_math/frontend/robots 필터
- Yoast SEO의 경우 카테고리에서 설정시 noindex 처리만 가능
- Rank Math SEO의 경우 카테고리에서도 noindex, nofollow 설정 가능
Yoast SEO
function wpseo_robots_filter($robotsstr) { if ( is_category(10157) || ( is_single() && in_category(10157) ) ) { return 'noindex,nofollow'; } return $robotsstr; } add_filter('wpseo_robots', 'wpseo_robots_filter');
Rank Math SEO
function rank_math_set_noindex_for_certain_categories($robots) {
if ( is_category([7, 49]) || ( is_single() && in_category([7, 49]) ) ) {
$robots['index'] = 'noindex';
$robots['follow'] = 'nofollow';
}
return $robots;
}
add_filter('rank_math/frontend/robots', 'rank_math_set_noindex_for_certain_categories');
'WordPress > Action Hook, Filter Hook, Function' 카테고리의 다른 글
플러그인 JS/CSS 미로딩 방법 (How to Disable CSS and JavaScript Added by Plugins) (1) | 2023.05.10 |
---|---|
워드프레스 검색 결과 페이지 커스텀 (0) | 2023.03.28 |
워드프레스 검색결과 개수 표시 (Display Total Results) (0) | 2023.03.28 |
워드프레스 guid 변경 쿼리문 (0) | 2023.03.22 |
language_attributes, bloginfo, ICL_LANGUAGE_CODE (0) | 2019.07.27 |