Last active
August 7, 2020 03:50
-
-
Save BoyetDgte/8a51c968a94ddd277a2192fb07b4bdd4 to your computer and use it in GitHub Desktop.
Exclude Scripts (Google tags, FB Pixel) on all blog posts and the blog page on a specific Multisite. Filter is added on Head, Footer and Body tag.
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
function excluding_blogs_header() { | |
// exclude from Posts Page (blog) page and all blog posts on the Main site (multisite) | |
if( !is_single() && !is_home() && 1 === get_current_blog_id() ) { | |
$code = "<script> Your script here </script>"; | |
} else { | |
$code = null; | |
} | |
echo $code; | |
} | |
add_action( 'wp_head', 'excluding_blogs_header', 15 ); | |
function excluding_blogs_footer() { | |
if( !is_single() && !is_home() && 1 === get_current_blog_id() ) { | |
$code = "<script> Your script here </script>"; | |
} else { | |
$code = null; | |
} | |
echo $code; | |
} | |
add_action( 'wp_footer', 'excluding_blogs_footer', 15 ); | |
function excluding_blogs_body() { | |
if( !is_single() && !is_home() && 1 === get_current_blog_id() ) { | |
$code = "<script> Your script here </script>"; | |
} else { | |
$code = null; | |
} | |
echo $code; | |
} | |
add_action( 'wp_body_open', 'excluding_blogs_body', 15 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment