{"id":1599,"date":"2019-12-08T13:06:24","date_gmt":"2019-12-08T05:06:24","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=1599"},"modified":"2019-12-08T13:07:55","modified_gmt":"2019-12-08T05:07:55","slug":"noindex-wordpress-subpages","status":"publish","type":"post","link":"https:\/\/www.intelliwolf.com\/noindex-wordpress-subpages\/","title":{"rendered":"How To Noindex WordPress Subpages"},"content":{"rendered":"\n
A technique commonly used in Search Engine Optimization (SEO) is to tell the search engines that you don't want particular pages to show up in the search results.<\/p>\n\n\n\n
The code you need in the HTML of the page is:<\/p>\n\n\n\n
<meta name='robots' content='noindex, follow'\/><\/code><\/pre>\n\n\n\nBecause the directive is to \"noindex, follow\", most people colloquially refer to that as \"noindexing\" the page.<\/p>\n\n\n\n
The easiest way to noindex particular pages is to use a plugin like Yoast SEO.<\/p>\n\n\n\n
Yoast SEO used to give you an option to noindex subpages, but they removed it in February 2018.<\/p>\n\n\n\n
The team at Yoast have their reasons for removing this option, but I want it, so this is how I coded it.<\/p>\n\n\n\n
How to set WordPress subpages to noindex<\/strong><\/h2>\n\n\n\nAdd this code to the functions.php<\/em> file of your child theme:<\/p>\n\n\n\nadd_action('wp_head', 'robot_meta_subpage_fix', 1);\nfunction robot_meta_subpage_fix() {\n if(is_paged()) {\n echo \"<meta name='robots' content='noindex, follow'\/>\", \"\\n\";\n }\n}<\/code><\/pre>\n\n\n\nThat will add a noindex tag just to subpages, like this:<\/p>\n\n\n\n