The issue was in my functions.php file. I had to remove each line one by one until I got the search working.
WordPress Custom Post Type Admin Search Doesn't Work
-
26-06-2023 - |
Вопрос
I've created a custom post type in WordPress and it's all working great except the search functionality of it pulls zero results. And the weirder thing, is that if I hit search a second time, it'll pull me into the default post section of WordPress.
It's very odd and I haven't found anything online to resolve this.
Any ideas on how to create a working admin search from a CPT in the backend of WordPress?
Code
// Register custom function
add_action( 'init', 'vendors', 0 );
// Create custom post-types
function vendors() {
register_post_type( 'vendors',
array(
'labels' => array(
'name' => 'Vendors',
'singular_name' => 'Vendor',
'add_new' => 'Add New',
'add_new_item' => 'Add New Vendor',
'edit' => 'Edit',
'edit_item' => 'Edit Vendor',
'new_item' => 'New Vendor',
'view' => 'View',
'view_item' => 'View Vendors',
'search_items' => 'Search Vendors',
'not_found' => 'No Vendors found',
'not_found_in_trash' => 'No Vendors found in Trash',
'parent' => 'Parent Vendor'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
'menu_icon' => '',
'has_archive' => true
)
);
}
Решение
Не связан с StackOverflow