How to stop the custom post type URL from the google search?
I don't have any issue with custom post type in the admin panel. It's working perfectly.
I have a small issue with search on google, I search my domain on google and I found the below output.
Note: This is just an example for reference.
My issue is, I don't want to show the below URL in the google search or any custom post type. Is there any way to stop?
I am using the Yoast plugin for SEO.
https://www.example.com/heroslider
I am using the below code.
// Register Custom Post Type heroslider
function create_heroslider_cpt() {
$labels = array(
'name' = _x( 'herosliders', 'Post Type General Name', 'textdomain' ),
'singular_name' = _x( 'heroslider', 'Post Type Singular Name', 'textdomain' ),
'menu_name' = _x( 'herosliders', 'Admin Menu text', 'textdomain' ),
'name_admin_bar' = _x( 'heroslider', 'Add New on Toolbar', 'textdomain' ),
'archives' = __( 'heroslider Archives', 'textdomain' ),
'attributes' = __( 'heroslider Attributes', 'textdomain' ),
'parent_item_colon' = __( 'Parent heroslider:', 'textdomain' ),
'all_items' = __( 'All herosliders', 'textdomain' ),
'add_new_item' = __( 'Add New heroslider', 'textdomain' ),
'add_new' = __( 'Add New', 'textdomain' ),
'new_item' = __( 'New heroslider', 'textdomain' ),
'edit_item' = __( 'Edit heroslider', 'textdomain' ),
'update_item' = __( 'Update heroslider', 'textdomain' ),
'view_item' = __( 'View heroslider', 'textdomain' ),
'view_items' = __( 'View herosliders', 'textdomain' ),
'search_items' = __( 'Search heroslider', 'textdomain' ),
'not_found' = __( 'Not found', 'textdomain' ),
'not_found_in_trash' = __( 'Not found in Trash', 'textdomain' ),
'featured_image' = __( 'Featured Image', 'textdomain' ),
'set_featured_image' = __( 'Set featured image', 'textdomain' ),
'remove_featured_image' = __( 'Remove featured image', 'textdomain' ),
'use_featured_image' = __( 'Use as featured image', 'textdomain' ),
'insert_into_item' = __( 'Insert into heroslider', 'textdomain' ),
'uploaded_to_this_item' = __( 'Uploaded to this heroslider', 'textdomain' ),
'items_list' = __( 'herosliders list', 'textdomain' ),
'items_list_navigation' = __( 'herosliders list navigation', 'textdomain' ),
'filter_items_list' = __( 'Filter herosliders list', 'textdomain' ),
);
$args = array(
'label' = __( 'heroslider', 'textdomain' ),
'description' = __( '', 'textdomain' ),
'labels' = $labels,
'menu_icon' = 'dashicons-format-gallery',
'supports' = array('title', 'editor', 'thumbnail', 'custom-fields'),
'taxonomies' = array(),
'public' = true,
'show_ui' = true,
'show_in_menu' = true,
'menu_position' = 5,
'show_in_admin_bar' = true,
'show_in_nav_menus' = true,
'can_export' = true,
'has_archive' = true,
'hierarchical' = true,
'exclude_from_search' = true,
'show_in_rest' = true,
'publicly_queryable' = true,
'capability_type' = 'post',
);
register_post_type( 'heroslider', $args );
}
add_action( 'init', 'create_heroslider_cpt', 0 );
Topic plugin-wp-seo-yoast google-search plugin-development custom-post-types Wordpress
Category Web