Last active
August 2, 2021 12:25
-
-
Save jchristopher/512654fb6d7a3a666468 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