I'am wondering how to target a search result page within the functions.php file in wordpress.
is_search, and the
I know about "is_search" for the search page but what about the search result page ?
They are the same thing,
is_search indicates the main query is a search query. When
is_search is true, WordPress loads
search.php as the template, falling back to
index.php if they aren't present.
I'm not sure where the idea of a separate search page, and a separate search results page came from, but that's not how it works. There are search results, and a search form that can appear in any place, but no search page.
Can we put a condition with the query or something?
If you want to modify the main query, use the
pre_get_posts filter. This is true for all queries, not just search queries, and allows you to intercept the query parameters before WordPress fetches the posts to change what's fetched.