@addison
To change the query search in WordPress, you can modify the search query using the pre_get_posts hook. Follow these steps:
1 2 3 4 5 6 7 8 |
function custom_search_filter($query) { if ($query->is_search && !is_admin()) { // Modify the search query here $query->set('post_type', 'post'); // Change post_type to the desired post type } return $query; } add_filter('pre_get_posts','custom_search_filter'); |
By using the pre_get_posts hook, you can customize the search query to suit your needs in WordPress.