Created
February 22, 2016 14:47
-
-
Save jtsternberg/d9013a849bce297c5bff to your computer and use it in GitHub Desktop.
blacklist/exclude page paths if the path starts with a certain string (for Google Analytics Top Content Widget)
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 | |
function gtc_pages_filter_automatically_remove_items( $pages ) { | |
$string_to_exclude = '/category/'; | |
foreach ( $pages as $index => $page ) { | |
// if path contains our excluded string, then remove it. | |
if ( false !== strpos( $page['path'], $string_to_exclude ) ) { | |
unset( $pages[ $index ] ); | |
} | |
} | |
return $pages; | |
} | |
add_filter( 'gtc_pages_filter', 'gtc_pages_filter_automatically_remove_items' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment