How to Exclude a WordPress Custom Post Type from Search
The below code will help to exclude a a custom post type from WordPress search.
<?php add_action('init', 'codex_custom_init'); function codex_custom_init() { $args = array( 'exclude_from_search' => false, // the important line here! 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author','thumbnail','excerpt','comments') ); register_post_type('book',$args); } ?> |