search ]

Add noindex to Specific Post Type

Sometimes you want search engines not to index a specific post type (e.g. landing pages). The following code adds noindex, nofollow to a specific CPT. For more on preventing search results from being indexed.

add_action( 'wp_head', function() {
	if ( is_singular( 'your_post_type' ) ) {
		echo '<meta name="robots" content="noindex, nofollow">' . "n";
	}
} );

Replace your_post_type with your CPT slug.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo