Exclude custom post types is not working correctly
-
To exclude almost every misc post types from indexing, I added such code
function exclude_post_types_from_indexing( $post_types ) {
// Post types to exclude
$exclude_post_types = [ 'page', 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block', 'wp_template', 'wp_template_part', 'wp_global_styles', 'wp_navigation', 'wp_font_family', 'wp_font_face', 'gp_elements', 'wbcr-snippets', 'ultp_builder', 'ultp_templates'];
// Loop through the post types to exclude
foreach ( $exclude_post_types as $exclude_post_type ) {
if ( isset( $post_types[ $exclude_post_type ] ) ) {
unset( $post_types[ $exclude_post_type ] );
}
}
return $post_types;
}
add_filter( 'ep_indexable_post_types', 'exclude_post_types_from_indexing' );But I still see some of them in the list in the plugin i.e.
Media (attachment)
Font Families (wp_font_family)
Font Faces (wp_font_face)
Elements (gp_elements)
Woody snippets (wbcr-snippets)
Builder (ultp_builder)
Saved templates (ultp_templates)
These shouldn’t have shown in the list as I excluded them above in the code.
Except Media, all other post types are private.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.