Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active April 10, 2020 15:33
Show Gist options
  • Save jchristopher/d110ed1641bc7d97a86e342171b76683 to your computer and use it in GitHub Desktop.
Save jchristopher/d110ed1641bc7d97a86e342171b76683 to your computer and use it in GitHub Desktop.
Add a Shortcode to exclude content from SearchWP's index
<?php
// Add a Shortcode to exclude content from SearchWP's index.
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