1. Archive Page with Yoast SEO
* 참고 : https://websamosa.com/how-to-noindex-category-in-yoast-seo/
* noindex, follow 처리됨
2. Single Post with wpseo_robots filter
Filter: 'wpseo_robots' - Allows filtering of the meta robots output of Yoast SEO.
* 참고1 : https://github.com/Yoast/wordpress-seo/issues/387
add_filter( 'wpseo_robots', 'wpseo_robots' );
/**
* Filter: 'wpseo_robots' - Allows filtering of the meta robots output of Yoast SEO.
*
* @param string $robotsstr The meta robots directives to be echoed.
* @return string
*/
function wpseo_robots( $robotsstr ) {
if ( is_single() && in_category( array( 23, 25 ) ) ) {
return 'noindex,follow';
}
return $robotsstr;
}
3. RSS Feed에서 제외 처리
* 참고1 : How to Exclude Specific Categories from WordPress RSS Feed : https://www.wpbeginner.com/wp-tutorials/how-to-exclude-specific-categories-from-wordpress-rss-feed/
* 참고2 : https://www.wpexplorer.com/exclude-wordpress-category-feed/
// Exclude Category with ID 17 from RSS feed
function exclude_feed_category($query) {
if ($query->is_feed) {
$query->set('cat', '-17');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_feed_category');
4. XML Sitemap & Google News에서 제외
- 불가. 하지만 1,2에서 noindex, nofollow 처리했기때문에 큰 의미없음.
5. 검색결과에서 제외
// Exclude specific categories from search result page of wordpess
function wpb_search_filter( $query ) {
if ( $query->is_search && !is_admin() )
$query->set('cat','-3339,-2415');
return $query;
}
add_filter('pre_get_posts', 'wpb_search_filter');