WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 months ago

#32903 closed enhancement (duplicate)

Url request order of priority - why "search" 3rd, after category, tag but before author, date, post etc?

Reported by: luciandavidescu Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.5
Component: Permalinks Keywords:
Focuses: Cc:

Description (last modified by earnjam)

I'm not too good at hooking into internal WP function, neither do I know if this particular hook could even be done (no documentation as far as I was able to search). I have this (http://stackoverflow.com/questions/31170657/redirecting-404-to-search-with-pagination-on-404-template/) situation where I need that the URL request be parsed into a search after anything else was exhausted.

By trial and error, I found that there is a list of priorities whenever an url is requested. First, WordPress will test if it's a category, if match serve, else test if tag, if match serve, else try a search. Anything else (author, date, custom taxonomy, post! etc) is parsed only after.

I know that this particular issue of mine wouldn't warrant any effort, but on the other hand, if there are no hard constraints preventing it, search would be much better suited at the very end of this queue. It's more logical that a search is absolutely the least specific type of url and it may also find it's way in numerous other applications.

So, IMO, url requests should be interpreted as a search only as the very last resort, either by default or at least via some documented hook into the code.

Change History (2)

#1 @Asif2BD
4 years ago

  • Keywords dev-feedback added

Thanks @luciandavidescu for your first ticket.

I would love to see Core Dev Feedback on it. If they feel the same we could look into it more.

#2 @earnjam
3 months ago

  • Description modified (diff)
  • Keywords dev-feedback removed
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from 4.2.2 to 1.5

Duplicate of #20067.

This is based off the order in which the default rules are registered inside WP_Rewrite->rewrite_rules()

It's been this way for a long time and there are very few recorded examples of it being a problem, so it seems like a pretty rare edge case.

There haven't been any updates on this ticket 4+ years, but the rules should be significantly filterable enough that you can change them to meet your unique requirements.

Note: See TracTickets for help on using tickets.