I worked it out for myself – just add a second code snippet!
I got the following from How to search custom posts by ID in WordPress dashboard on Codexin
/**
* Add search custom posts by their ID in WordPress dashboard
*
*/
add_action( 'parse_request', 'cdxn_search_by_id' );
function cdxn_search_by_id( $wp ) {
global $pagenow;
if( !is_admin() && 'edit.php' != $pagenow && 'students' !== $_GET['post_type']) {
return;
}
// If it's not a search return
if( !isset( $wp->query_vars['s'] ) ) {
return;
}
// Validate the numeric value
$id = absint( substr( $wp->query_vars['s'], 0 ) );
if( !$id ) {
return;
}
unset( $wp->query_vars['s'] );
$wp->query_vars['p'] = $id;
}
Related Posts:
- Using meta query (‘meta_query’) with a search query (‘s’)
- Including custom fields in search?
- Add custom fields to search
- Custom search: by post data and post metadata?
- Need small coding with Custom Fields Search
- Search ONLY by meta key / meta values
- Filter results with custom field values and dropdown
- Add custom field (value) to search result (without plugin)
- Is there a way to do multiple ordering on a multiple meta_query?
- searching in custom meta field
- WordPress Search Custom Meta Field Only
- Exclude custom post type from search by custom field value?
- Extend ‘The Events Calendar’ search to include custom fields [closed]
- Include woocommerce custom field value in front-end search result
- Including Database Generated Pages in Site Search [closed]
- Adding Custom Fields to Search
- sort search results by custom fields using dropdown
- Using a checklist to search against metadata
- How do I use wp_query for WordPress search?
- Custom Fields Not in Search Results
- How make a custom search on backend in WordPress without plugin?
- filtering custom post types via meta data drop down
- Advanced search by two criteria – sort by location and date (ascending or descending)
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Advanced search for meta fields
- Merge Multiple Custom Fields into one New Custom Field for Searching
- How to populate custom field dropdown box based on prior selection?
- Search in Archive Pages by subcategory, tag, custom field and year
- Custom WP_Query for WordPress Search Results with meta_query
- filter custom field values $min $max
- Restrict WordPress Search to Custom Field
- How can you include custom post meta in search without calling each key?
- Include one custom field in search results
- Custom search SQL Query to add custom field in result
- Search Results Page – Displaying Custom Meta Fields
- Custom field Search with Relavanssi
- How to exclude custom fields from search queries?
- How to show content of custom fields in search results?
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Type character in name and make it invisble
- Search & column order by meta value in admin
- search based on custom field
- Very large list of options for BuddyPress profile fields
- searching by keywords in post’s metas or pagination links problem
- Search fails when using the radio buttons
- Admin – Search Events by a custom field
- Search one custom field?
- Create custom query for search?
- Query postmeta values, and return multiple post_titles for common meta value
- Query Custom Fields in Searchform
- Help sorting by Meta Key value
- Custom search with meta fields
- How to display search query as formatted text?
- Search for meta_query does not return any result if combined with title
- How to enable custom fields for pages (if not a bad practice)?
- Custom per-page sidebar widgets .. possible?
- How to add new custom page or post blocks?
- How to update serialized data in the user meta data
- Unable to save datetime custom meta field using update_post_meta() function
- Guest Author – How can I use custom fields to create guest author link?
- enabling custom fields in admin?
- Get aggregate list of all custom fields for entire blog
- How to Identify the Source of a Custom Field?
- How to save multiple options from a dropdown in user profile
- How to display multiple images in custom field
- How to show a gloabl message on a user profile page (in back end)?
- adding extra wordpress user info from registration form
- Custom Meta Box (SELECT) Not Saving
- filter search custom field query
- Turn raw url into clickable links
- Get post ids sorted by meta_key
- Advanced Custom Fields Plugin – Unable to get URL from post_object
- Plot location on Google map using full address specified in custom field
- Display custom field value as a hyperlink
- Unable to get specific value from post meta
- Displaying Custom Field Array
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- Custom Field Repeating When Using foreach
- Help setting up a sql query
- Help with this custom field conditional if no field is set display nothing
- if statement display content even though no data
- Get custom post fields from multiple metaboxes
- Get author total post votes from post meta
- How to display custom fields in hestia theme
- How to update only certain custom fields in a the cache of a page?
- variable not passed correctly to database using custom field
- WordPress Blocks, setAttributes not saving
- non-unique #_ajax_nonce id in browser console
- Why does this javascript search function in the WordPress Admin not work?
- 4 Unique Random Posts based on Custom Field Values
- Get meta value when the page is a blog archive
- Add Image With Changeable Link in Custom Field [closed]
- Create download page from post option link
- How to Pull Out Twitter Summary Data in other areas of my template?
- query specific posts according their custom fields, using sql SELECT
- Should I use a Meta field or custom table?
- Associate an image with a post to show it in a slideshow
- Dynamic background image used in css after selector
- doesn’t save custom meta box data wordpress