-
-
Save searchwpgists/e65a3c401b1ea5b173780e0f8dcfe69e to your computer and use it in GitHub Desktop.
Add a Shortcode to exclude content from SearchWP's index
This file contains 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 | |
// Add a Shortcode to exclude content from SearchWP's index. | |
// @link https://searchwp.com/documentation/knowledge-base/prevent-indexing-segments-of-content/ | |
add_shortcode( 'searchwp_no_index', function( $atts, $content = null ) { | |
// If the indexer is running do not return anything, | |
// else return the content contained in the Shortcode. | |
return did_action( 'searchwp\indexer\batch' ) ? '' : $content; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment