Last active
February 10, 2025 21:18
-
-
Save cliffordp/f4ac939df52f1ba7f3120801eea43a32 to your computer and use it in GitHub Desktop.
Squirrly SEO: Custom Meta Robots for custom post type (CPT) archives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Squirrly SEO: Custom Meta Robots for custom post type (CPT) archives. | |
* | |
* Set `<meta name="robots" content="noindex,nofollow">` for WPAutoTerms archives (e.g. /terms page). | |
* | |
* Must be a priority AFTER 11 and BEFORE 99 due to the plugin's own use | |
* of this same filter hook in squirrly-seo/models/services/Noindex.php | |
* | |
* @link https://gist.github.com/cliffordp/f4ac939df52f1ba7f3120801eea43a32 This snippet. | |
* @link https://squirrly.feedbear.com/boards/squirrly-seo/posts/automation-ability-to-control-indexing-for-each-post-type-s-archive-instead-of-all-archives-of-all-post-types | |
*/ | |
add_filter( 'sq_noindex', 'squirrlyseo_custom_meta_robots_for_cpt_archives', 90 ); | |
function squirrlyseo_custom_meta_robots_for_cpt_archives( array $robots ) { | |
if ( is_post_type_archive( 'wpautoterms_page' ) ) { | |
$robots[0] = 'noindex'; | |
$robots[1] = 'nofollow'; | |
} | |
return $robots; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment