search posts by POST ID
The function you are using might not be working because WordPress’s search functionality has been updated, and it’s recommended to use WordPress’s WP_Query class to modify the main query. Here’s a better and safer way to search by post ID using pre_get_posts hook: function search_by_post_id($query) { if($query->is_search) { if(is_numeric($query->query_vars[‘s’])) { $query->set(‘post_type’, ‘any’); $query->set(‘post__in’, array((int)$query->query_vars[‘s’])); $query->set(‘s’, … Read more