Skip to content

Instantly share code, notes, and snippets.

@nickcernis
Created August 17, 2015 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickcernis/41ec69737e639c0ac3c9 to your computer and use it in GitHub Desktop.
Save nickcernis/41ec69737e639c0ac3c9 to your computer and use it in GitHub Desktop.
Don't process a WordPress shortcode in wp_head
<?php
global $wp_current_filter;
// Don't process this shortcode in wp_head. This typically happens if a plugin author
// uses apply_filters( 'the_content', $content ) for the meta description tag output,
// instead of using strip_shortcodes() like a sane person. Processing shortcodes in
// the head might be undesirable if your shortcode counts the number of times it's
// been used for the purpose of outputting unique class names or IDs, for example.
if ( in_array('wp_head', $wp_current_filter) ) {
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment