I have a post type registered with this code, however 'exclude_from_search' => true
seems to have no effect as I still find output in the search page. Am I making some mistake?
add_action('init', 'abundant_life_slides_register');
function abundant_life_slides_register() {
$args = array(
'label' => 'Slides',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'has_archive' => false,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'slides'),
'query_var' => true,
'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'),
'labels' => array (
'name' => 'Slides',
'singular_name' => 'Slide',
'menu_name' => 'Slides',
'add_new' => 'Add Slide',
'add_new_item' => 'Add New Slide',
'edit' => 'Edit',
'edit_item' => 'Edit Slide',
'new_item' => 'New Slide',
'view' => 'View Slide',
'view_item' => 'View Slide',
'search_items' => 'Search Slides',
'not_found' => 'No Slides Found',
'not_found_in_trash' => 'No Slides Found in Trash',
'parent' => 'Parent Slide',
'exclude_from_search' => true,
));
register_post_type('slides', $args);
}
Your
exclude_from_search
is currently inside your nested labels array. You need to move it up.