Skip to content

Instantly share code, notes, and snippets.

@jeherve
Last active December 19, 2015 19:49
Show Gist options
  • Save jeherve/6008795 to your computer and use it in GitHub Desktop.
Save jeherve/6008795 to your computer and use it in GitHub Desktop.
Check if a post includes a Gallery, and include a X-UA-Compatible to the head
<?php
function jeherve_check_galleries( $post ) {
global $post;
if ( false !== strpos( $post->post_content, '[gallery' ) )
echo '<meta http-equiv="X-UA-Compatible" content="IE=8" />';
}
add_action( 'wp_head', 'jeherve_check_galleries' );
@jeherve
Copy link
Author

jeherve commented Jul 16, 2013

Note: when WP 3.6 will be out, you can use has_shortcode instead:

function jeherve_check_galleries( $post ) {
    global $post;

    if ( has_shortcode( $post->post_content, 'gallery' ) )
        echo '<meta http-equiv="X-UA-Compatible" content="IE=8" />';
}
add_action( 'wp_head', 'jeherve_check_galleries' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment