-
-
Save BrElio/e2d86a2f5d3c801edd5dd44c174cc15a to your computer and use it in GitHub Desktop.
Use a Shortcode to prevent SearchWP from indexing partial content, see https://searchwp.com/docs/kb/prevent-indexing-segments-content/
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 | |
// tell SearchWP to process shortcodes | |
add_filter( 'searchwp_do_shortcode', '__return_true' ); | |
// if the SearchWP indexer is running prevent returning the | |
// content between [searchwp_no_index] and [/searchwp_no_index] | |
function shortcode_searchwp_no_index( $atts, $content = null ) { | |
// if the searchwp_indexer_running action fired, the indexer is running so don't return anything | |
return did_action( 'searchwp_indexer_running' ) ? '' : $content; | |
} | |
add_shortcode( 'searchwp_no_index', 'shortcode_searchwp_no_index' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment