Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#38703 closed enhancement (worksforme)

parse_search() before pre_get_posts hook

Reported by: drzraf's profile drzraf Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

When hooking pre_get_posts(), $query->get('s') may be of interest (in order, eg, to change some meta condition).
But it's currently not possible because this query_vars is initialized far later in the get_posts() workflow (by parse_search()).

Is there anything which keeps core from doing parse_search() earlier?
If not, could we provide query_vars['s'] to implementers of pre_get_posts?

Change History (1)

#1 @desrosj
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
  • Version 4.7 deleted

Hi @drzraf,

Sorry that it took so long for someone to respond to this ticket.

I just did some testing and when hooking into pre_get_posts, I see the value searched for at the s index in the query and query_vars arrays. It's possible that a different ticket addressed this. I was unable to find one, though.

I am going to close this out as worksforme. But, if you are still having issues with the search value not being included when hooking pre_get_posts, feel free to reopen and provide more details to reproduce.

Note: See TracTickets for help on using tickets.