Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Created April 25, 2023 07:37
Show Gist options
  • Save maheshwaghmare/0ae7ca3f57dd9a33f790772d009f94c1 to your computer and use it in GitHub Desktop.
Save maheshwaghmare/0ae7ca3f57dd9a33f790772d009f94c1 to your computer and use it in GitHub Desktop.
Exclude post type from rank math analytics. Here we excluded the `plgnoptmzr_work` post type from the Rank Math analytics screens. Note: After adding the code just update any single excluded post type once so the Rank Math re-analyze and exclude the post type from the database.
<?php
if ( ! function_exists( 'prefix_rank_math_excluded_post_types' ) ) :
function prefix_rank_math_excluded_post_types( $post_types = [] ) {
// Add the post types which you want to exclude.
$excludes = [
'plgnoptmzr_work',
];
return array_diff_key( $post_types, array_flip( $excludes ) );
}
add_filter( 'rank_math/excluded_post_types', 'prefix_rank_math_excluded_post_types' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment