As a new post type in WordPress to bring in the search?

Created a new record type in WordPress in the following way:
public function register_type_post_init()
 $labels = array(
 'name' => 'Paid subscriptions',
 'singular_name' => 'Paid subscription', // Add->Function
 'add_new' => 'Create order',
 'add_new_item' => 'Create new order', // Title tag <title>
 'edit' => 'Edit',
 'edit_item' => 'Edit job',
 'new_item' => 'New order',
 'all_items' => 'All orders',
 'view_item' => 'View orders',
 'search_items' => 'Search for order',
 'not_found' => 'Order not found.',
 'not_found_in_trash' => 'In the shopping basket was not found.',
 'menu_name' => 'Paid subscriptions', // Name of the menu item in the admin panel
 'filter_items_list' => 'Filter orders',
 'items_list_navigation' => 'Navigation orders',
 'items_list' => 'List orders'
 $args = array(
 'labels' => $labels,
 'description' => 'This is the paid orders paid subscriptions.',
 'public' => false,
 'show_ui' => true, // Show in the admin panel
 'map_meta_cap' => true,
 'publicly_queryable' => false,
 'exclude_from_search' => false,
 'rewrite' => true,
 'query_var' => false,
 'has_archive' => false,
 'menu_icon' => 'dashicons-list-view', // Icon in the menu
 'menu_position' => 9, // the Order in the menu
 'permalink_epmask' => EP_NONE, // Disable URL
 'register_meta_box_cb' => 'subscribes_orders::add_order_meta_box',
 'supports' => array('title'), // place fields "Title", "Description", "custom fields"
 register_post_type('subs-orders', $args);

When searching in the admin panel on the page the new record type are displayed for some reason all the materials that are on the site and not the type of record which I created. Although in the address string specified.
It looks like the page you are writing:
When I do a search on this page, the output is with posts that do not belong to the type of records on the page, which I am. In General, it is necessary that the search searched only among orders.
What can causes of this behavior, please tell me. I would be very grateful.
March 12th 20 at 08:40
1 answer
March 12th 20 at 08:42
The problem is solved! A big thank you to @HectorPrima for his response in the comments to the question. Sent in the right direction. Now learn more about what was the reason of the problem. In my case, the file functions.php a filter was applied (similarly, there's a hook) 'pre_get_posts'. It is triggered before each call to the database using the class WP_Query. And changed the type of posts among which there was a search.
Code which was the problem
function excludePages($query)
 $query->set('post_type', 'post');
 return $query;

The solution is quite simple. You need to install the test being in the admin panel.
Fixed code
function excludePages($query)
 if($query->is_search) // If the query in the database is sent as a result of the search on the site
 if(!is_admin()) $query->set('post_type', 'post'); // If the user is not in admin panel
 return $query;

Maybe someone can help my answer in the future.

Find more questions by tags WordPress