Skip to content

Instantly share code, notes, and snippets.

@jtsternberg
Last active February 22, 2016 14:45
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 jtsternberg/5d00f2a9c541906e8534 to your computer and use it in GitHub Desktop.
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)
<?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