To do that, you’ll have to use one of the built-in filters and put a snippet in your theme’s functions.php file. To remove specific paths, you can use this snippet:
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' );
If you want to remove all pages that start with “/category/” you could do that like this:
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' );