Last active
February 22, 2016 14:45
-
-
Save jtsternberg/5d00f2a9c541906e8534 to your computer and use it in GitHub Desktop.
blacklist/exclude certain page paths from results (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_manually_remove_items( $pages ) { | |
$page_paths_to_exclude = array( | |
'/category/category-slug', | |
'/category/2nd-category-slug', | |
); | |
foreach ( $pages as $index => $page ) { | |
if ( in_array( $page['path'], $page_paths_to_exclude, true ) ) { | |
unset( $pages[ $index ] ); | |
} | |
} | |
return $pages; | |
} | |
add_filter( 'gtc_pages_filter', 'gtc_pages_filter_manually_remove_items' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment