Last active
July 16, 2024 11:53
-
-
Save wpmudev-sls/5567d07d07b7b55f6c9f74dc79e0cf65 to your computer and use it in GitHub Desktop.
[SmartCrawl Pro] - Exclude specific category posts from indexing
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 | |
| /** | |
| * Plugin Name: [SmartCrawl Pro] Exclude specific category posts from indexing | |
| * Description: Exclude specific category posts from indexing. | |
| * Author: Prashant @ WPMUDEV | |
| * Task: SLS-6316 | |
| * Author URI: https://premium.wpmudev.org | |
| * License: GPLv2 or later | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; // Exit if accessed directly. | |
| } | |
| add_filter( 'wp_robots', 'wpmudev_exclude_specific_category_posts', 9999 ); | |
| function wpmudev_exclude_specific_category_posts( $robots ) { | |
| if ( is_singular( 'post' ) && has_category( 'xy' ) ) { // Please change the category name and post type. | |
| $robots['noindex'] = true; | |
| $robots['nofollow'] = true; | |
| } | |
| return $robots; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment