Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.